php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54011 array_merge_recursive does not use free numeric keys
Submitted: 2011-02-14 09:12 UTC Modified: 2011-02-28 15:59 UTC
From: j dot henge-ernst at interexa dot de Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.3.5 OS: linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: j dot henge-ernst at interexa dot de
New email:
PHP Version: OS:

 

 [2011-02-14 09:12 UTC] j dot henge-ernst at interexa dot de
Description:
------------
If you use array_merge_recursive to join arrays which have different numeric keys, free keys are nor used if the later array has a key which is below the first/highest key.

Test script:
---------------
var_dump(array_merge_recursive(
array("a" => array(5 => "7")),
array("a" => array(3 => "8"))
));'


Expected result:
----------------
array(1) {
  ["a"]=>
  array(2) {
    [3]=>
    string(1) "8"
    [5]=>
    string(1) "7"
  }
}


Actual result:
--------------
array(1) {
  ["a"]=>
  array(2) {
    [5]=>
    string(1) "7"
    [6]=>
    string(1) "8"
  }
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-28 15:59 UTC] iliaa@php.net
-Status: Open +Status: Bogus
 [2011-02-28 15:59 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


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 22:01:29 2024 UTC