|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2012-01-19 17:01 UTC] rasmus@php.net
-Status: Open
+Status: Bogus
[2012-01-19 17:01 UTC] rasmus@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 02 15:00:01 2025 UTC |
Description: ------------ Hello, I think I found a bug in array_multisort, when trying to sort a multi-dimensional array, which has string keys containing only digits. On the resulting array, those keys are suppressed, and replaced by '0' for the first one, '1' for the second... I had this error on PHP version 5.3.6, and on the last PHP 5.4 Snap revision: 322462, downloaded from php.net (tested with no .ini file) Test script: --------------- $t = array( 'AZE' => array('SORT' => 'order #2', 'FOO' => 'xx'), '123' => array('SORT' => 'order #3', 'FOO' => 'xx'), 'RTY' => array('SORT' => 'order #5', 'FOO' => 'xx'), '654' => array('SORT' => 'order #1', 'FOO' => 'xx'), 'UIO' => array('SORT' => 'order #4', 'FOO' => 'xx'), ); $W_ORDER = array(); foreach($t as $key => $row) $W_ORDER[(string)$key] = $row['SORT']; array_multisort( $W_ORDER, SORT_ASC, SORT_STRING, $t ); print_r($t); Expected result: ---------------- Array ( [654] => Array ( [SORT] => order #1 [FOO] => xx ) [AZE] => Array ( [SORT] => order #2 [FOO] => xx ) [123] => Array ( [SORT] => order #3 [FOO] => xx ) [UIO] => Array ( [SORT] => order #4 [FOO] => xx ) [RTY] => Array ( [SORT] => order #5 [FOO] => xx ) ) Actual result: -------------- Array ( [0] => Array ( [SORT] => order #1 [FOO] => xx ) [AZE] => Array ( [SORT] => order #2 [FOO] => xx ) [1] => Array ( [SORT] => order #3 [FOO] => xx ) [UIO] => Array ( [SORT] => order #4 [FOO] => xx ) [RTY] => Array ( [SORT] => order #5 [FOO] => xx ) )