|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-10-02 16:29 UTC] sniper@php.net
[2005-07-18 09:49 UTC] dmitry@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 09 02:00:01 2025 UTC |
Description: ------------ Seems, that multidimensional arrays are copied with one dimension, which contains references to other included arrays. I haven't found any references in manual, so this must be a bug. Reproduce code: --------------- <?php $a[0]['id'] = array(22, 12, 33, 55); $a[0]['secid'] = array("a","b","c","d"); print_r($a); $b = $a; foreach ($b as $k => $v) { array_multisort($v['id'], SORT_DESC, $v['secid'], SORT_DESC); } print_r($a); ?> Expected result: ---------------- Array ( [0] => Array ( [id] => Array ( [0] => 22 [1] => 12 [2] => 33 [3] => 55 ) [secid] => Array ( [0] => a [1] => b [2] => c [3] => d ) ) ) Array ( [0] => Array ( [id] => Array ( [0] => 22 [1] => 12 [2] => 33 [3] => 55 ) [secid] => Array ( [0] => a [1] => b [2] => c [3] => d ) ) ) Actual result: -------------- Array ( [0] => Array ( [id] => Array ( [0] => 22 [1] => 12 [2] => 33 [3] => 55 ) [secid] => Array ( [0] => a [1] => b [2] => c [3] => d ) ) ) Array ( [0] => Array ( [id] => Array ( [0] => 55 [1] => 33 [2] => 22 [3] => 12 ) [secid] => Array ( [0] => d [1] => c [2] => a [3] => b ) ) )