The array_replace_recursive()
function recursively replaces the value of the first array with the value of the following array.
Tip: You can pass an array, or multiple arrays to the function.
If a key exists in the first array array1 and also in the second array2 , the value in the first array array1 will be replaced by the value in the second array array2 . If a key exists only in the first array array1 , it will remain unchanged. If a key exists in the second array array2 but does not exist in the first array array1 , this element is created in the first array array1 . If multiple replacement arrays are passed, they will be processed in sequence, and the values of the subsequent array will overwrite the values of the previous array.
Note: If no key is specified for each array, the function's behavior will be equivalent to array_replace()
function.
array_replace_recursive ( array1 , array2 , array3 ... )
parameter | describe |
---|---|
array1 | Required. Specify array. |
array2 | Optional. Specifies an array to replace the value of array1 . |
array3 ,... | Optional. Specifies multiple arrays to replace values of array1 and array2 , .... The value of the subsequent array will overwrite the value of the previous array. |