php.net |  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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
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
Description:
------------
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)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-11-30 17:27 UTC] tony2001@php.net
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:
<?php
$array1 = array();
$array2 = array(1 => "data");
$result = $array1 + $array2;
?>

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

:-((((((
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC