I have an array of date like
a[0]=>2013-10-05
a[1]=>2013-10-25
a[2]=>2013-10-15
a[3]=>2013-10-28
I want to sort in ascending order. How can i sort this?
I have an array of date like
a[0]=>2013-10-05
a[1]=>2013-10-25
a[2]=>2013-10-15
a[3]=>2013-10-28
I want to sort in ascending order. How can i sort this?
Try the default sort function as stated here: Sort by Date
Or use a custom sort function like suggested here: Custom Search Function
function sortFunction( $a, $b )
{
//$a and $b are two values from your array
//Return a value > 0 then $a is greater than $b
return strtotime($a) - strtotime($b);
}
usort($data, "sortFunction");