-1

I want to sort this array alphabetically .I am defining my array here.I am calling it in foreach loop Here is my code:

private static $table_prefixes = [
        'alio',
        'dan_travel',
        'goway_ca',
        'goway_us',
        'picasso',
        'transam'
];

  public $suppliers_overview = [];
 public static function getTablePrefixes()
    {
        return self::$table_prefixes;
    }

 foreach (self::getTablePrefixes() as $prefix) {

            $this->suppliers_overview[$prefix]['name'] =$prefix;
}
1

1 Answer 1

0

You can try this in place of your foreach

$this->suppliers_overview[] = array_sort_recursive(self::getTablePrefixes());
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.