Problem with usort

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

 



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

-- 
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