Answer the question
In order to leave comments, you need to log in
How to sort multidimensional array by time in php?
How can I rearrange this array by the time
field so that each item element is sorted in ascending order?
For clarity:
$arr['date']['type']['item']['time'];
$arr['2021.06.25']['type'][0]['20:45:00'];
$arr['2021.06.25']['type'][1]['06:00:00'];
$arr['2021.06.25']['type'][2]['13:20:00'];
$arr['2021.06.25']['type'][0]['06:00:00'];
$arr['2021.06.25']['type'][1]['13:20:00'];
$arr['2021.06.25']['type'][2]['20:45:00'];
Answer the question
In order to leave comments, you need to log in
Perhaps so?
sort($arr['2021.06.25']['type']);
print_r($arr);
Array
(
[2021.06.25] => Array
(
[type] => Array
(
[0] => 06:00:00
[1] => 13:20:00
[2] => 20:45:00
)
)
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question