Bug #75483 [NEW]: array_replace_recursive will merge (not replace), when both values are arrays
| From: | gladykov at gmail dot com | Date: | Fri, 03 Nov 2017 15:08:36 +0000 |
| Subject: | Bug #75483 [NEW]: array_replace_recursive will merge (not replace), when both values are arrays | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-212434@lists.php.net to get a copy of this message | ||
From: gladykov at gmail dot com
Operating system:
PHP version: 7.1.11
Package: Arrays related
Bug Type: Bug
Bug description:array_replace_recursive will merge (not replace), when both values are arrays
Description:
------------
array_replace_recursive will merge (not replace) values, when both key
values in original and replacement matching key are arrays.
When one of values either in original key or replacement key is string,
replacement will occur properly.
Test script:
---------------
<?php
//If value of availableReport key will be string in $original OR
$replacement array_replace_recursive will work properly
$original = [
'availableReports' => ['InternalReview' => 'Internal Review'],
];
$replacements = [
'availableReports' => ['AppraisalRev' => 'Commercial Appraisal
Review']
];
//Will print both values in current implementation
print_r(array_replace_recursive($original, $replacements));
?>
Expected result:
----------------
Array
(
[availableReports] => Array
(
[AppraisalRev] => Commercial Appraisal Review
)
)
Actual result:
--------------
Array
(
[availableReports] => Array
(
[InternalReview] => Internal Review
[AppraisalRev] => Commercial Appraisal Review
)
)
--
Edit bug report at https://bugs.php.net/bug.php?id=75483&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75483&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75483&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75483&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75483&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75483&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75483&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75483&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75483&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75483&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75483&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75483&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75483&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75483&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75483&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75483&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75483&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75483&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75483&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75483&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75483&r=mysqlcfg