Guest Deleted Posted January 14, 2014 Share Posted January 14, 2014 A friend pointed out that the manual says usort callback functions are supposed to return 1 or -1. I was wondering why Larry has them return true or false? This is from page 3: function asc_number_sort($x,$y) { if ($x['key1'] > $y['key1']) { return true; } elseif ($x['key1'] < $y['key1']) return false; } else { return 0; ) usort($a, 'asc_number_sort'); From the manual: "The comparison function must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second." (http://us3.php.net/usort) Link to comment Share on other sites More sharing options...
HartleySan Posted January 14, 2014 Share Posted January 14, 2014 true is equal to 1, and false is equal to 0 (loosely speaking). Link to comment Share on other sites More sharing options...
Recommended Posts