Edit report at http://bugs.php.net/bug.php?id=54143&edit=1

 ID:                 54143
 Updated by:         [email protected]
 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

Reply via email to