I have an array whose keys are date which i want to sort in ascending order. I tried sorting it out with ksort() and other sort method which didn't work out. Sorting out with usort() also didn't work.
this is my array
array:7 [▼
"21-07-2017" => array:1 [▶]
"04-09-2017" => array:3 [▶]
"27-07-2017" => array:1 [▶]
"31-07-2017" => array:1 [▶]
"01-08-2017" => array:2 [▶]
"05-09-2017" => array:1 [▶]
"15-09-2017" => array:1 [▶]
]
this is what i did.
usort($date, function($a, $b) {
foreach ($a as $value1) {
foreach ($b as $value2) {
return ($value1['date'] < $value2['date']) ? -1 : 1;
}
}
});
Are there any in built functions in php which i am missing ?