[ create a new paste ] login | about

Link: http://codepad.org/tmwnyNtd    [ raw code | output | fork ]

PHP, pasted on Dec 2:
1
2
3
4
5
6
7
8
9
10
11
12
<?php
$array = array("2011-September_38","2011-June_4","2010-November_9","2011-November_29","2010-December_19");
function monthCompare($a, $b) {
   $arrA = explode('_', $a);
   $arrB = explode('_', $b);
   $da = strtotime($arrA[0]);
   $db = strtotime($arrB[0]);
   return $da > $db;
}
usort($array, "monthCompare");
print_r($array);
?>


Output:
1
2
3
4
5
6
7
8
Array
(
    [0] => 2010-November_9
    [1] => 2010-December_19
    [2] => 2011-June_4
    [3] => 2011-September_38
    [4] => 2011-November_29
)


Create a new paste based on this one


Comments: