I am trying to order this array chronologically:
$ta = array (
0 => '20/05/2012',
1 => '08/01/2011',
2 => '23/10/2010',
3 => '27/07/2013',
4 => '28/01/2011',
5 => '21/10/2010',
5 => '18/07/2013',
);
function comp2($a, $b) {
if ($a == $b)
return 0;
return ($a < $b) ? 1 : -1;
};
usort($ta,'comp2');
This returns:
Array
(
[0] => 28/01/2011
[1] => 27/07/2013
[2] => 23/10/2010
[3] => 20/05/2012
[4] => 18/07/2013
[5] => 08/01/2011
)
I have also converted dates with strtotime
after changing to mm/dd/yyyy
to no avail.