|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-06-21 12:54 UTC] cmb@php.net
-Status: Open
+Status: Verified
-Type: Bug
+Type: Documentation Problem
[2018-06-21 12:54 UTC] cmb@php.net
[2018-06-21 13:23 UTC] german dot drulyk at gmail dot com
[2018-06-21 20:54 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 16:00:01 2025 UTC |
Description: ------------ I am not sure which behavior is the bug but the root array gets re-indexed to 0 and 1 and the array at position "k" goes from 4 to 5. array_merge() exhibits the same behavior with the root array. Test script: --------------- $arr1 = array( 4 => 'a', 'k' => array( 4 => 'a' ) ); $arr2 = array( 5 => 'b', 'k' => array( 5 => 'b' ) ); $arr3 = array_merge_recursive( $arr1, $arr2 ); var_dump( $arr3 ); Expected result: ---------------- array(3) { [0]=> // Should this be 4? string(1) "a" ["k"]=> array(2) { [4]=> // or should this be 0? string(1) "a" [5]=> // or should this be 1? string(1) "b" } [1]=> // Should this be 5? string(1) "b" } Actual result: -------------- array(3) { [0]=> string(1) "a" ["k"]=> array(2) { [4]=> string(1) "a" [5]=> string(1) "b" } [1]=> string(1) "b" }