Doc #52048 [Opn->Bgs]: array_merge_recursive not make it clear if former or latter takes precedenence

From: Date: Wed, 08 Sep 2010 15:03:30 +0000
Subject: Doc #52048 [Opn->Bgs]: array_merge_recursive not make it clear if former or latter takes precedenence
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-5000@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=52048&edit=1 ID: 52048 Updated by: cataphract@php.net Reported by: matt at mediaequals dot com Summary: array_merge_recursive not make it clear if former or latter takes precedenence -Status: Open +Status: Bogus Type: Documentation Problem Package: Documentation problem Operating System: all PHP Version: Irrelevant Block user comment: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2010-06-11 11:33:42] 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. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52048&edit=1

« previous php.doc.bugs (#5000) next »