PHP 4.0 Bug #9645: usort, uasort, uksort fail every other time
| From: | busterb at mail dot utexas dot edu | Date: | Fri, 09 Mar 2001 06:40:12 +0000 |
| Subject: | PHP 4.0 Bug #9645: usort, uasort, uksort fail every other time | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-48379@lists.php.net to get a copy of this message | ||
From: busterb@mail.utexas.edu
Operating system: FreeBSD 4.0 Release
PHP version: 4.0.4pl1
PHP Bug Type: Arrays related
Bug description: usort, uasort, uksort fail every other time
usort, uasort and uksort all fail to sort an array
properly every other time they are called, unless the
array is reset() after each call.
This is a snippet from a class that fails every other time
it is called.
var $sort_field;
function cmp ($a, $b) {
return ($a[$this -> sort_field] > $b[$this ->
sort_field]);
}
function sort_records ($sort_field) {
$this -> sort_field = $sort_field;
uasort ($this -> record_data, array($this, "cmp"));
}
--
Edit Bug report at: http://bugs.php.net/?id=9645&edit=1