|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-06-11 11:33 UTC] matt at mediaequals dot com
Description: ------------ The array_merge documentation includes the essential words "If the input arrays have the same string keys, then the later value for that key will overwrite the previous one." A similar statement does not exist for array_merge_recursive. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 08 14:00:02 2026 UTC |
That's because the behavior of the two differ in that aspect: <?php $arr1 = array("a"=>1); $arr2 = array("a"=>2); print_r(array_merge($arr1,$arr2)); print_r(array_merge_recursive($arr1,$arr2)); gives Array ( [a] => 2 ) Array ( [a] => Array ( [0] => 1 [1] => 2 ) ) This is clearly explained in the docs for array_merge_recursive, including the example.