#35494 [Bgs]: Array merge problem
| From: | marek dot rybar at dial dot sk | Date: | Fri, 02 Dec 2005 15:43:27 +0000 |
| Subject: | #35494 [Bgs]: Array merge problem | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-89647@lists.php.net to get a copy of this message | ||
ID: 35494
User updated by: marek dot rybar at dial dot sk
Reported By: marek dot rybar at dial dot sk
Status: Bogus
Bug Type: Arrays related
Operating System: Windows, Linux
PHP Version: 5.1.1
New Comment:
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
:-((((((
Previous Comments:
------------------------------------------------------------------------
[2005-11-30 17:27:34] tony2001@php.net
Expected behaviour.
Use array_merge_recursive() to get the result you expect.
------------------------------------------------------------------------
[2005-11-30 17:20:41] 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)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=35494&edit=1