note 129412 added to function.array-replace
| From: | vlk.charles@gmail.com | Date: | Fri, 19 Apr 2024 07:58:07 +0000 |
| Subject: | note 129412 added to function.array-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221295@lists.php.net to get a copy of this message | ||
I think it is worth mentioning that the array passed as the first argument is not modified and is
left intact. A new array is returned. I think the wording of this documentation could be improved
because it suggests that the passed array *is* modified.
If you want to modify your existing array, it is not enough to do:
array_replace($arrayToModify, $arrayWithModifications);
You have to assign the returned value back to it like so:
$arrayToModify = array_replace($arrayToModify, $arrayWithModifications);
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.13.131 (proxied: 2001:1ae9:1100:e297:c93b:af63:a065:5bf0)
----
Manual Page -- https://php.net/manual/en/function.array-replace.php
Edit -- https://main.php.net/note/edit/129412
Del: integrated -- https://main.php.net/note/delete/129412/integrated
Del: useless -- https://main.php.net/note/delete/129412/useless
Del: bad code -- https://main.php.net/note/delete/129412/bad+code
Del: spam -- https://main.php.net/note/delete/129412/spam
Del: non-english -- https://main.php.net/note/delete/129412/non-english
Del: in docs -- https://main.php.net/note/delete/129412/in+docs
Del: other reasons-- https://main.php.net/note/delete/129412
Reject -- https://main.php.net/note/reject/129412
Search -- https://main.php.net/manage/user-notes.php