php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #17303 Error in array_merge
Submitted: 2002-05-18 05:18 UTC Modified: 2002-05-18 05:55 UTC
From: hardword at web dot de Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.2.0 OS: Mandrake 8.2
Private report: No CVE-ID: None
 [2002-05-18 05:18 UTC] hardword at web dot de
$array1=();
$array2=(1=>"data");
print_r(array_merge($array1,$array2));

/*
this will print out 

array (
  0 => "data"
)

and should be

array (
  1=>"data"
)
*/

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-18 05:36 UTC] mfischer@php.net
Expected, but probably not well documented behaviour. Only string keys are preserverd.

Use $merged_array = $array1 + $array2; for your purpose.

Making a documentation problem.
 [2002-05-18 05:55 UTC] mfischer@php.net
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at http://snaps.php.net/. In case this was a documentation 
problem, the fix will show up soon at http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites.
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 05 15:01:34 2025 UTC