update page now
International PHP Conference Berlin 2026

Voting

: seven minus two?
(Example: nine)

The Note You're Voting On

harl at gmail dot com
11 months ago
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);
?>

<< Back to user notes page

To Top