I have an array like this below,
Array
(
[2] => Array
(
[id] => 75
[program] => Apr 2020-Nov 2020
)
[1] => Array
(
[id] => 73
[program] => Feb 2016-Aug 2020
)
[0] => Array
(
[id] => 72
[program] => May 2020-Dec 2020
)
)
The resultant array should be
Array
(
[1] => Array
(
[id] => 73
[current_program] => Feb 2016-Aug 2020
)
[2] => Array
(
[id] => 75
[current_program] => Apr 2020-Nov 2020
)
[0] => Array
(
[id] => 72
[current_program] => May 2020-Dec 2020
)
)
It should sort based on the year. I have tried to achieve by "strnatcasecmp", but the array is sorting by alphabet not by the numeric value in it
usort($programp, function($a, $b) {
return strnatcasecmp($a['program'], $b['program']);
});
Any help would be appreciated!
Thanks
Ain April comes beforeFin February.