Bug #76505 [NEW]: array_merge_recursive() is duplicating sub-array keys
| From: | german dot drulyk at gmail dot com | Date: | Wed, 20 Jun 2018 13:29:37 +0000 |
| Subject: | Bug #76505 [NEW]: array_merge_recursive() is duplicating sub-array keys | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-215809@lists.php.net to get a copy of this message | ||
From: german dot drulyk at gmail dot com
Operating system: https://3v4l.org/
PHP version: 7.2.6
Package: Arrays related
Bug Type: Bug
Bug description:array_merge_recursive() is duplicating sub-array keys
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 bug report at https://bugs.php.net/bug.php?id=76505&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76505&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76505&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76505&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=76505&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=76505&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=76505&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=76505&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=76505&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=76505&r=support
Expected behavior: https://bugs.php.net/fix.php?id=76505&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=76505&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=76505&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=76505&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76505&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=76505&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=76505&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=76505&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76505&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=76505&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=76505&r=mysqlcfg