I have an array like
Array ( [0] => Luke Karizo => Jul 18 2021 [1] => telse Elarazo => Aug 15 2021 [2] => Sarath S => Jul 08 2021 )
I am trying to reorder or sort the elements based on the date values in it. What I have tried is
function date_sort($a, $b) {
return strtotime($a) - strtotime($b);
}
usort($main_Array, "date_sort");
print_r($main_Array);
I am expecting a result like
Array ( [0] => Sarath S => Jul 08 2021 [1] => Luke Karizo => Jul 18 2021 [2] => telse Elarazo => Aug 15 2021)
Is there any way I can sort this array based on the date values? Any help would be appreciated.