note 129944 added to function.array-replace

From: Date: Wed, 08 Jan 2025 01:26:01 +0000
Subject: note 129944 added to function.array-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-221757@lists.php.net to get a copy of this message
This function *adds* keys from replacement arrays to the new array as well as replacing the values of existing ones, which may not be what you want (or expect). If you only want actual *replacements* of existing values, when the replacement arrays might have additional keys not in the original, then a quick bit of sanitation is called for: <?php $with_replacements = array_replace($original, ...$replacement_arrays); $with_replacements = array_intersect_key($with_replacements, $original); ?> ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.137 (proxied: 222.153.153.210) ---- Manual Page -- https://php.net/manual/en/function.array-replace.php Edit -- https://main.php.net/note/edit/129944 Del: integrated -- https://main.php.net/note/delete/129944/integrated Del: useless -- https://main.php.net/note/delete/129944/useless Del: bad code -- https://main.php.net/note/delete/129944/bad+code Del: spam -- https://main.php.net/note/delete/129944/spam Del: non-english -- https://main.php.net/note/delete/129944/non-english Del: in docs -- https://main.php.net/note/delete/129944/in+docs Del: other reasons-- https://main.php.net/note/delete/129944 Reject -- https://main.php.net/note/reject/129944 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221757) next »