note 8587 added to usort
| From: | derek at luddite dot net | Date: | Tue, 19 Sep 2000 03:35:39 +0000 |
| Subject: | note 8587 added to usort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-5204@lists.php.net to get a copy of this message | ||
Needed a date sort and I didn't know if one was available so I wrote one. Maybe it'll help
someone:
function DateSort($a,$b,$d="-") {
if ($a == $b)
{ return 0; }
else { //Convert into dates and compare
list($am,$ad,$ay)=split($d,$a);
list($bm,$bd,$by)=split($d,$b);
if (mktime(0,0,0,$am,$ad,$ay) < mktime(0,0,0,$bm,$bd,$by))
{ return -1; }
else { return 1; }
}
}
$d is the delimeter
http://www.php.net/manual/function.usort.php