note 8587 modified in function.usort by irc-html

From: Date: Sun, 20 Jan 2002 00:50:24 +0000
Subject: note 8587 modified in function.usort by irc-html
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-25542@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 --was-- 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/en/function.usort.php

« previous php.notes (#25542) next »