Problem with usort

From: Date: Thu, 04 May 2006 15:46:43 +0000
Subject: Problem with usort
Groups: php.general 
Request: Send a blank email to php-general+get-235523@lists.php.net to get a copy of this message
Hi folks, Config is Apache/1.3.34 (Unix) PHP/4.4.1 mod_ssl/2.8.25 OpenSSL/0.9.7i. If my usort callback has in it: if ($aday == $bday) {return 0;} else {return ($aday < $bday) ? -1 : 1;} everything works - lots of sort operations happen on the array (three elements) and it sorts correctly. If however, I change it to: $ret_val = 0; if ($aday == $bday) {$ret_val = 0;} else {$ret_val = ($aday < $bday) ? -1 : 1;} return ret_val; Then it does not sort correctly and only performs two sort operations (on a three element array). I must be missing something obvious. I'm not the most experienced PHP coder so perhaps some esoteric feature of the language has confounded me. Open to liberal use of the clue by four. :) Cheers! Jon

« previous php.general (#235523) next »