|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-03-23 13:37 UTC] iliaa@php.net
[2004-03-24 21:02 UTC] ashok at yahoo-inc dot com
[2004-03-26 14:45 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 00:00:02 2025 UTC |
Description: ------------ When using array_merge to merge 2 arrays, the order of elements of the first are changed. The keys are all integers unlike other existing bugs where keys are mixed integers and strings. Reproduce code: --------------- <?php $string1 = "1|Text|0-0-0-0-0-0-0"; list ($arr1[0], $arr1[1], $string2) = explode ("|", $string1, 3); print ("Values of arr1 after first explode...\n"); for ($i = 0; $i < count ($arr1); $i++) print ("arr1[$i] = " . $arr1[$i] . "\n"); print ("\nValues of arr1 after second explode...\n"); $arr1 = array_merge ($arr1, explode ('-', $string2)); for ($i = 0; $i < count ($arr1); $i++) print ("arr1[$i] = " . $arr1[$i] . "\n"); ?> ~ Expected result: ---------------- arr1[0] = 1 arr1[1] = Text arr1[2] = 0 arr1[3] = 0 arr1[4] = 0 arr1[5] = 0 arr1[6] = 0 arr1[7] = 0 arr1[8] = 0 Actual result: -------------- arr1[0] = Text arr1[1] = 1 arr1[2] = 0 arr1[3] = 0 arr1[4] = 0 arr1[5] = 0 arr1[6] = 0 arr1[7] = 0 arr1[8] = 0