|
array_replace_recursiveReplaces elements from passed arrays into the first array recursively Description
array array_replace_recursive(array
$array , array ...$replacements )
array_replace_recursive replaces the values of
array_replace_recursive is recursive : it will recurse into arrays and apply the same process to the inner value. When the value in the first array is scalar, it will be replaced by the value in the second array, may it be scalar or array. When the value in the first array and the second array are both arrays, array_replace_recursive will replace their respective value recursively. Parameters
Return ValuesReturns an array. Examples
Example #1 array_replace_recursive example
The above example will output: Array ( [citrus] => Array ( [0] => pineapple ) [berries] => Array ( [0] => blueberry [1] => raspberry ) ) Array ( [citrus] => Array ( [0] => pineapple ) [berries] => Array ( [0] => blueberry ) ) Example #2 array_replace_recursive and recursive behavior
The above example will output: Array ( [citrus] => Array ( [0] => pineapple ) [berries] => Array ( [0] => blueberry [1] => raspberry ) [others] => litchis ) See Also
|