Bug #54143 [Opn->Bgs]: array_merge returns NULL if a parameter is NULL
| From: | dtajchreber@php.net | Date: | Wed, 02 Mar 2011 22:17:08 +0000 |
| Subject: | Bug #54143 [Opn->Bgs]: array_merge returns NULL if a parameter is NULL | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-159173@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=54143&edit=1
ID: 54143
Updated by: dtajchreber@php.net
Reported by: mchotai at fulcrum dot ca
Summary: array_merge returns NULL if a parameter is NULL
-Status: Open
+Status: Bogus
Type: Bug
Package: Arrays related
Operating System: Ubuntu 9.3
PHP Version: 5.3SVN-2011-03-02 (SVN)
Block user comment: N
Private report: N
New Comment:
It also gives you a warning explaining that parameter 1 isn't an array.
If you
want your output, cast NULL to an array:
var_dump(array_merge((array)NULL, array('a', 'b')));
array(2) {
[0]=>
string(1) "a"
[1]=>
string(1) "b"
}
Previous Comments:
------------------------------------------------------------------------
[2011-03-02 22:44:19] mchotai at fulcrum dot ca
Description:
------------
$userdata = array_merge($user, $userdata);
If $user is NULL the result is NULL instead of $userdata.
Test script:
---------------
$userdata = array("Hi", "Jim");
$userdata = array_merge(NULL, $userdata);
Expected result:
----------------
Get back $userdata = array("Hi", "Jim")
Actual result:
--------------
NULL
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=54143&edit=1