Created
August 18, 2014 07:56
-
-
Save GiovanniK/de0fdf9b08fcdd0b9f10 to your computer and use it in GitHub Desktop.
Sort array (descending or ascending)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static function do_sort($a, $b) { | |
$date = $a->publishOn; | |
$date2 = $b->publishOn; | |
$aval = strtotime($date); | |
$bval = strtotime($date2); | |
if ($aval == $bval) { | |
return 0; | |
} | |
return $aval > $bval ? -1 : 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment