|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-07-12 05:47 UTC] hholzgra@php.net
[2002-07-12 05:59 UTC] glimpse at glimpse dot fr dot fm
[2002-07-12 06:13 UTC] hholzgra@php.net
[2002-07-12 07:33 UTC] glimpse at glimpse dot fr dot fm
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 11:00:01 2025 UTC |
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?