Bug #18299: arsort works different on PHP 4.1.2 and PHP 4.2.0
| From: | glimpse at glimpse dot fr dot fm | Date: | Fri, 12 Jul 2002 09:19:10 +0000 |
| Subject: | Bug #18299: arsort works different on PHP 4.1.2 and PHP 4.2.0 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-13930@lists.php.net to get a copy of this message | ||
From: glimpse@glimpse.fr.fm
Operating system: Linux RedHat 6.2
PHP version: 4.2.0
PHP Bug Type: Feature/Change Request
Bug description: arsort works different on PHP 4.1.2 and PHP 4.2.0
It seems like the arsort() function sort associative array strangely. The
same script does not give the same result:
$fruits =
array("d"=>"test","a"=>"test","b"=>"test","c"=>"test");
arsort ($fruits);
for (reset ($fruits); $key = key ($fruits); next ($fruits)) {
echo "fruits[$key] = ".$fruits[$key]."\n";
}
Result with PHP 4.1.2 :
fruits[d] = test fruits[a] = test fruits[b] = test fruits[c] = test
(with this order : d, a, b, c)
Result with PHP 4.2.0 :
fruits[c] = test fruits[b] = test fruits[a] = test fruits[d] = test
(with this order : c, b, a, d)
Why does the arsort() function change the order of the elements when they
have the same value in PHP 4.2.0 while not in PHP 4.1.2?
--
Edit bug report at http://bugs.php.net/?id=18299&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=18299&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=18299&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=18299&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=18299&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=18299&r=support
Expected behavior: http://bugs.php.net/fix.php?id=18299&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=18299&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=18299&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=18299&r=globals