|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25762 array_merge returns NULL if one input array isn't set
Submitted: 2003-10-06 14:05 UTC Modified: 2003-10-06 16:46 UTC
From: flaimo at gmx dot net Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5CVS-2003-10-06 (dev) OS: win xp
Private report: No CVE-ID: None
 [2003-10-06 14:05 UTC] flaimo at gmx dot net
if i use array_merge with two arrays, where one array-variable isn't set, the function returns NULL instead of the values of the other array.

Reproduce code:
error_reporting(E_ALL & E_NOTICE); 
$array2 = array(1, 'a', TRUE); 
$array3 = array_merge($array2, $array1); // $array1 isn't set

Expected result:
works like this in PHP4:

undefined variable array1; 

should return array(1, 'a', true);

Actual result:
behaves like this in PHP5 snap:

undefined variable array1; 

returns NULL;


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-06 16:16 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

All arguments to the function must be arrays, otherwise the function will fail. That is to be expected.
 [2003-10-06 16:46 UTC] flaimo at gmx dot net
well but if a failure is the expected result, than it's a php4 bug and php5 is correct, since php4 returns an array containing the values of $array2. if this is a wanted change from php4 to php5 it should be made public somewhere.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 22 17:01:29 2024 UTC