|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2017-11-03 15:16 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
[2017-11-03 15:16 UTC] requinix@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 11:00:01 2025 UTC |
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 ) )