php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #4875 array_merge() is unable to merge arrays with numeric keys
Submitted: 2000-06-07 19:29 UTC Modified: 2003-01-04 11:19 UTC
From: waldschrott at kiffen dot de Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.0.0 Release OS: all
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: waldschrott at kiffen dot de
New email:
PHP Version: OS:

 

 [2000-06-07 19:29 UTC] waldschrott at kiffen dot de
array_merge() is unable to merge arrays with numeric keys (as described in the documentation), however that?s usefull sometimes and should be possible, in face of the fact that even casting the keys to (string) they?re saved as (int)s.

workaround:
to merge arrays with numeric keys you can save all keys with a string prefix 'a'.$int for example, after extracting the key do a substr($key,1)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-04 11:19 UTC] andrey@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip

 Seems that F/CR is old.
The docs read :

If you want to completely preserve the arrays and just want to append them to each other, use the + operator: 

$array1 = array();
$array2 = array(1 => "data");
$result = $array1 + $array2;

So I think to close this.

Thank you for your report.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 07 14:01:37 2025 UTC