|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-09-15 12:20 UTC] aharvey@php.net
-Status: Open
+Status: Assigned
-Type: Bug
+Type: Documentation Problem
-Assigned To:
+Assigned To: aharvey
[2010-09-15 12:20 UTC] aharvey@php.net
[2010-09-15 12:29 UTC] aharvey@php.net
[2010-09-15 12:29 UTC] aharvey@php.net
-Status: Assigned
+Status: Closed
[2010-09-15 12:29 UTC] aharvey@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 08 18:00:02 2026 UTC |
Description: ------------ Not sure if this a documentation problem or a function problem, but either way, it is a bug :-) The documentation for array_merge says "If all of the arrays contain only numeric keys, the resulting array is given incrementing keys starting from zero." However, integer keys are always renumbered even if there is a non-numeric key present. Test script: --------------- <?php $test = array('foo' => false, 1=>2.34, 2=>13.12); var_dump($test); $result = array_merge(array(),$test); var_dump($result); Expected result: ---------------- array(3) { ["foo"]=> bool(false) [1]=> float(2.34) [2]=> float(13.12) } array(3) { ["foo"]=> bool(false) [1]=> float(2.34) [2]=> float(13.12) } Actual result: -------------- array(3) { ["foo"]=> bool(false) [1]=> float(2.34) [2]=> float(13.12) } array(3) { ["foo"]=> bool(false) [0]=> float(2.34) [1]=> float(13.12) }