|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #23816 modified array_merge_recursive: array_merge_clobber
Submitted: 2003-05-26 13:18 UTC Modified: 2014-12-30 10:41 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: pacha_shevaev at mail dot ru Assigned:
Status: No Feedback Package: *General Issues
PHP Version: * OS: Any
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: pacha_shevaev at mail dot ru
New email:
PHP Version: OS:


 [2003-05-26 13:18 UTC] pacha_shevaev at mail dot ru
It's not probably a bug report but a suggestion.
Guys please could you make built-in function array_merge_clobber that WOULDN'T append duplicate key/values like array_merge_recursive does?

There's an example of such function in the php manual, in the array_merge_recursive section:

function array_merge_clobber($a1,$a2) {
if(!is_array($a1) || !is_array($a2)) return false;
$newarray = $a1;
foreach ($a2 as $key => $val) {
        if (is_array($val) && is_array($newarray[$key])) {
$newarray[$key] = array_merge_clobber($newarray[$key],$val);
} else {
$newarray[$key] = $val;
return $newarray;

Our application heavily depends on this function and it takes about 40% of overall script execution(very large and nested arrays)! I think many developers would agree to have this function interbally implemented.

Maybe it's not the right place...but i have no idea where else i could ask about it...


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-04-16 18:27 UTC]
-Status: Open +Status: Feedback -Package: Feature/Change Request +Package: *General Issues -Operating System: win2000 +Operating System: Any -PHP Version: 4.3.1 +PHP Version: *
 [2014-04-16 18:27 UTC]
If I understand you correctly, the `+` operator can be used:

$array1 = array(0 => 'zero_a', 2 => 'two_a', 3 => 'three_a');
$array2 = array(1 => 'one_b', 3 => 'three_b', 4 => 'four_b');
$result = $array1 + $array2;
 [2014-12-30 10:41 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Dec 09 16:01:27 2023 UTC