Re: Problem with usort
| From: | Martin Alterisio \"El Hombre Gris\" | Date: | Thu, 04 May 2006 16:36:59 +0000 |
| Subject: | Re: Problem with usort | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-235534@lists.php.net to get a copy of this message | ||
Rabin Vincent escribió:
On 5/4/06, Jon Earle <je_php@kronos.honk.org> wrote:$ret_val = 0; if ($aday == $bday) {$ret_val = 0;} else {$ret_val = ($aday < $bday) ? -1 : 1;} return ret_val;You're missing the $ for ret_val on the return line. PHP thus understands the return value as a string, "ret_val", which would be taken as 0. Since all elements are now equal, the order of the elements in the array is undefined. Rabin Actually, PHP first looks for a constant named "ret_val", then it uses a string containing "ret_val". So, if there was a constant with that name, that value would have been used.