|
array_replaceReplaces elements from passed arrays into the first array Description
array array_replace(array
$array , array ...$replacements )array_replace creates a new array and assigns items into it for each key in each of the provided arrays. If a key appears in multiple input arrays, the value from the right-most input array will be used. array_replace does not process elements items recursively, it replaces the entire value for each key when it does a replacement. Parameters
Return ValuesReturns an array. Examples
Example #1 array_replace example
The above example will output: array(5) { [0]=> string(5) "grape" [1]=> string(6) "banana" [2]=> string(5) "apple" [3]=> string(9) "raspberry" [4]=> string(6) "cherry" } Example #2 Example of how nested arrays are handled
The above example will output: array(2) { ["citrus"]=> array(2) { [0]=> string(7) "kumquat" [1]=> string(6) "citron" } ["pome"]=> array(1) { [0]=> string(6) "loquat" } } See Also
|