[ create a new paste ] login | about

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

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


Output:

Warning: Wrong parameter count for strstr() on line 4

Warning: Wrong parameter count for strstr() on line 5

Warning: Wrong parameter count for strstr() on line 4

Warning: Wrong parameter count for strstr() on line 5

Warning: Wrong parameter count for strstr() on line 4

Warning: Wrong parameter count for strstr() on line 5

Warning: Wrong parameter count for strstr() on line 4

Warning: Wrong parameter count for strstr() on line 5

Warning: Wrong parameter count for strstr() on line 4

Warning: Wrong parameter count for strstr() on line 5

Warning: Wrong parameter count for strstr() on line 4

Warning: Wrong parameter count for strstr() on line 5
Array
(
    [0] => 2010-December_19
    [1] => 2011-November_29
    [2] => 2010-November_9
    [3] => 2011-June_4
    [4] => 2011-September_38
)


Create a new paste based on this one


Comments: