|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2000-08-05 12:08 UTC] stas@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 18 07:00:02 2025 UTC |
When keys in associative arrays are only composed of integers, the concerned lines of the table are converted to non-associative lines, after passing through array_merge(). With keys composed of strings or mixed integers-strings, this misbehaviour doesn't occur. $array1 = array ("foo" => "bar", "bla" => "blabla"); $array2 = array ("123" => "one two three", "456" => "four five six"); while (list ($key, $val) = each ($array1)) print "$key : $val \n"; /* this returns : foo : bar bla : blabla it's correct */ while (list ($key, $val) = each ($array2)) print "$key : $val \n"; /* this returns : 123 : one two three 456 : four five six it's also correct */ $array3 = array_merge ($array1, $array2); while (list ($key, $val) = each ($array3)) print "$key : $val, "; /* this returns : foo : bar bla : blabla 0 : one two three 1 : four five six strange, isn't it ? */ Note: I've installed mandrake-cooker rpm's of php4, as the rpms shipped with redhat 6.2 are only old 3.something. Perhaps this can be the cause of the problem ? I haven't tried to reproduce the bug on another system.