Bug #76505 [Opn]: array_merge_recursive() is duplicating sub-array keys
| From: | german dot drulyk at gmail dot com | Date: | Wed, 20 Jun 2018 13:30:49 +0000 |
| Subject: | Bug #76505 [Opn]: array_merge_recursive() is duplicating sub-array keys | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-215810@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76505&edit=1
ID: 76505
User updated by: german dot drulyk at gmail dot com
Reported by: german dot drulyk at gmail dot com
Summary: array_merge_recursive() is duplicating sub-array
keys
Status: Open
Type: Bug
Package: Arrays related
Operating System: https://3v4l.org/
PHP Version: 7.2.6
Block user comment: N
Private report: N
New Comment:
PHP 4.x and 5.x produce the expected result but PHP 7.x does not.
Previous Comments:
------------------------------------------------------------------------
[2018-06-20 13:29:36] german dot drulyk at gmail dot com
Description:
------------
Keys are duplicated in the sub-array.
Test script:
---------------
<?php
$array1 = array(
'k' => array(
2 => 100,
98 => 200,
)
);
$array2 = array(
'k' => array(
64 => 300
)
);
$array3 = array_merge_recursive( $array1, $array2 );
echo '<pre>';
var_dump( $array3 );
echo 'count: '.count( $array3['k'] );
Expected result:
----------------
array(1) {
["k"]=>
array(3) {
[2]=>
int(100)
[98]=>
int(200)
[99]=>
int(300)
}
}
count: 3
Actual result:
--------------
array(1) {
["k"]=>
array(3) {
[2]=>
int(100)
[98]=>
int(200)
[2]=>
int(300)
}
}
count: 3
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76505&edit=1