array_replace
Replaces elements from passed arrays into the first array
&reftitle.description;
arrayarray_replace
arrayarray
arrayreplacements
array_replace is not mutating
array_replace is not recursive
array_replace creates a new array by joining all given arrays in given order, replacing values of already existing keys.
&reftitle.parameters;
array
The array in which elements are replaced.
replacements
Arrays from which elements will be extracted.
Values from later arrays overwrite the previous values.
&reftitle.returnvalues;
Returns an array.
&reftitle.examples;
array_replace example
"pineapple", 4 => "cherry");
$replacements2 = array(0 => "grape");
$basket = array_replace($base, $replacements, $replacements2);
print_r($basket);
?>
]]>
&example.outputs;
grape
[1] => banana
[2] => apple
[3] => raspberry
[4] => cherry
)
]]>
&reftitle.seealso;
array_replace_recursive
array_merge