The array_replace() function is used to replace elements from passed arrays into one array. While using the array_replace() function, if an array contains a key that is already present in another array, the value of the key gets replaced from the value in the second array. If the key is present only in the second array and not in the first one, it gets added to the first array with the same value in the second array. If the key is present only in the first array, there is no change. Hence, in the above script, the output will be as follows: