I have an array being created which contains a date:
$arr = array();
$arr["one"][] = array(
'due' => '17-01-2021 10:00:00',
);
$arr["one"][] = array(
'due' => '17-01-2021 09:00:00',
);
$arr["two"][] = array(
'due' => '19-01-2021 09:00:00',
);
$arr["two"][] = array(
'due' => '18-01-2021 09:00:00',
);
And I want to order by the value of the 'due' key
I tried adding this uasort function:
uasort($arr, function ($a, $b) {
return $a["due"] <=> $b["due"];
});
print_r($arr);
But that still shows in the order above, whereas it should be showing the '09:00:00' value first
uasortfunction, surely it'd be easier for you to create a loop, or is this an issue for performance?$arr["one"], so use this as the array to sort, and both sides of your test are$b["due"]$ret