PHP array_replace() function replaces elements of first array with other passed array. The array_replace() function is PHP built-in function.
array_replace() replaces the values of array with values having the same keys in each of the following arrays. If the key exists in the second array but not in the first, it will be created in the first array.
Syntax :
array_replace ( array $array , array $replacement1, array $replacement2 , ........);
Parameter,
$array : It is first array . It is used to replace value of it.
$replacement1 : It is replacement array which is used to replace value of first array.
$replacement2 : It is replacement array which is used to replace value of first array and first replacement array.
Note : Later array can replace value of previously array in array_replace function.
Return : The array_replace() function returns array with replaced value. It will return null if an error occurs.
Let's see below example to understand php array_replace() Function in details.
At below example, array_replace() function return replaced array $tutorials after replacing value of $array1 by arrays $array2 and $array3.
Comments