I have a really big array containing the following data:
Array
(
[2] => Array
(
[Berlin] => Array
(
[1] => Array
(
[0] => stdClass Object
(
[name] => Joe
[car_name] => Audi
[car_color] => Black
[sid] => 130
)
[1] => stdClass Object
(
[name] => Mark
[car_name] => BMW
[car_color] => Red
[sid] => 135
)
)
[0] => Array
(
[0] => stdClass Object
(
[name] => Lucas
[car_name] => Audi
[car_color] => Yellow
[sid] => 168
)
[1] => stdClass Object
(
[name] => Joe
[car_name] => Volkswagen
[car_color] => Black
[sid] => 170
)
[2] => stdClass Object
(
[name] => Thomas
[car_name] => Ford
[car_color] => Gray
[sid] => 119
)
)
)
[Moscow] => Array
(
[1] => Array
(
[0] => stdClass Object
(
[name] => Matt
[car_name] => Mustang
[car_color] => Black
[sid] => 230
)
[1] => stdClass Object
(
[name] => Suze
[car_name] => Lada
[car_color] => Red
[sid] => 245
)
)
[0] => Array
(
[0] => stdClass Object
(
[name] => Lucas
[car_name] => Unknown
[car_color] => Brown
[sid] => 374
)
[1] => stdClass Object
(
[name] => Mathew
[car_name] => Volkswagen
[car_color] => Blue
[sid] => 589
)
[2] => stdClass Object
(
[name] => Thomas
[car_name] => Ford
[car_color] => Light Blue
[sid] => 741
)
)
)
)
)
Now I would like to sort it like this (please read the // lines):
Array
(
[2] => Array //from min to max - eg. from 0 to 50
(
[Berlin] => Array //alphabetically from A to Z
(
[1] => Array //from min to max eg. from 0 to 1
(
)
)
)
)
How can I achieve this in PHP? I hope I was clear enough, feel free to ask in the comments for the additional info.
Would be something like this:
Documentation on Array and Array Functions:
https://www.php.net/manual/en/book.array.php
Functional Example
This example is real specific to your example; however, you could make a recursive style function if your array structure is really dynamic.