I am trying to order an array by its date. I have tried to do this using usort but it will not change the order of the array in any way?
I am trying to show oldest near the start, and newest near the bottom.
usort($history, function($a, $b) {
return strtotime($a['date']) < strtotime($b['date']) ? 1 : -1;
});
Array structure:
array:3 [
0 => array:3 [
"date" => "13/02/2020",
"event" => "validate",
"note" => "",
]
1 => array:3 [
"date" => "02/02/2020",
"event" => "created",
"note" => "",
]
2 => array:3 [
"date" => "03/04/2020",
"event" => "approved",
"note" => "",
]
]