|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35494 Array merge problem
Submitted: 2005-11-30 17:20 UTC Modified: 2005-12-02 16:43 UTC
From: marek dot rybar at dial dot sk Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.1.1 OS: Windows, Linux
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: marek dot rybar at dial dot sk
New email:
PHP Version: OS:


 [2005-11-30 17:20 UTC] marek dot rybar at dial dot sk
When I merge two arrays using + operator, result is array only with the first array elements.

Reproduce code:
$arr1 = array(1, 2, 3);
$arr2 = array(5, 6, 7);
$arr = $arr1 + $arr2;

result $arr:
array(1, 2, 3)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-11-30 17:27 UTC]
Expected behaviour.
Use array_merge_recursive() to get the result you expect.
 [2005-12-02 16:43 UTC] marek dot rybar at dial dot sk
Why do you think that is bogus? If it's true, please remove from manual this passage:

If you want to completely preserve the arrays and just want to append them to each other, use the + operator:
$array1 = array();
$array2 = array(1 => "data");
$result = $array1 + $array2;

because $result is $array1 not $array1 + $array2

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Nov 27 06:03:14 2021 UTC