Replace values in first associative array ($a1) with values in second array ($a2) with extra keys in PHP
Description
The following code shows how to replace values in first associative array ($a1) with values in second array ($a2) with extra keys.
Example
/*w w w .j av a 2 s . com*/
//If a key exists in array2 and not in array1
<?php
$a1=array("a"=>"red","green");
$a2=array("a"=>"orange","b"=>"Basic");
print_r(array_replace($a1,$a2));
?>
The code above generates the following result.