I have an array of dates and I have to sort it by using the described functions.
Here is what I have:
$dates = array (\'10-10-2003\', \'2-17-2002\', \'2-
In your date_tim_timestamp function, you are essentially throwing away your date in place of the integer value.
Try this instead:
function date_to_timestamp($d){
$newarr = array();
foreach($d as $f) {
$arr=explode("-",$f);
//array_push($newarr, mktime(0,0,0,$arr[0],$arr[1],$arr[2]));
$int_version = mktime(0,0,0,$arr[0],$arr[1],$arr[2]);
$newarr[$int_version] = $f;
}
return $newarr;
}
Using this approach, you wont need to use usort(), just ksort()