#38266 [Bgs]: array += operator broken
| From: | jason at jasonjustman dot com | Date: | Mon, 31 Jul 2006 10:48:53 +0000 |
| Subject: | #38266 [Bgs]: array += operator broken | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-100140@lists.php.net to get a copy of this message | ||
ID: 38266
User updated by: jason at jasonjustman dot com
Reported By: jason at jasonjustman dot com
Status: Bogus
Bug Type: Arrays related
Operating System: linux/windows
PHP Version: 4.4.2
New Comment:
Please refer to the following docs page:
< http://us3.php.net/manual/en/function.array-merge.php
>
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;
?>
i know that array_merge is the proper function to use in my previous
test case, for the output. but, regardless, if the key association is
being maintaed in my previous test case, the output should really be
[0] => d [1]=>e [2]=>c
please revisit, or redoc on the manpage.
Previous Comments:
------------------------------------------------------------------------
[2006-07-31 08:51:07] tony2001@php.net
This is how it works in 4.3.0, 4.3.6, 4.3.11, 5.0.x.
No bug here.
------------------------------------------------------------------------
[2006-07-31 08:38:14] jason at jasonjustman dot com
Description:
------------
array += operator is now broken in 4.4.1 and 4.4.2
Reproduce code:
---------------
<?
$x = array("a","b","c");
$x +=array("d","e");
print_r($x);
Expected result:
----------------
Array ( [0] => a [1] => b [2] => c [3] => d [4] => e)
Actual result:
--------------
Array ( [0] => a [1] => b [2] => c )
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=38266&edit=1