php.net |  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
Description:
------------
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:
---------------
<?php 
error_reporting(E_ALL & E_NOTICE); 
$array2 = array(1, 'a', TRUE); 
$array3 = array_merge($array2, $array1); // $array1 isn't set
var_dump($array3); 
?>  


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;

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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

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-2021 The PHP Group
All rights reserved.
Last updated: Thu Dec 09 02:03:35 2021 UTC