Re: Problem with usort

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Rabin Vincent escribió:
On 5/4/06, Jon Earle <je_php@xxxxxxxxxxxxxxx> 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.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux