I've got an multidimensional array like this:
Array
(
[thursday] => Array
(
[0] => Array
(
[title] => Movie2
[time] => 15.30
[venue] => VenueA
)
[1] => Array
(
[title] => Movie1
[time] => 13.00
[venue] => VenueB
)
)
)
I want to sort it by time using array_multisort and this is going fine when I use it like this:
foreach ($movies['thursday'] as $key => $row) {
$time[$key] = $row['time'];
}
array_multisort($time, SORT_ASC, $movies['thursday']);
unset($time);
But in this way, I have to repeat this code for each day of the week. So I'd like to use:
foreach ($movies as $movie) {
foreach ($movie as $key => $row) {
$time[$key] = $row['time'];
}
array_multisort($time, SORT_ASC, $movie);
unset($time);
}
But now the array remains unsorted. As far as I can see the latter piece of code is functional equal to the former piece of code. Or am I making a huge conceptual mistake?