There are condition when we have two array and want to combine them. In PHP, we can use function array_merge() to merge those to array.
Below is the example how to use the function.
$a1=array("a"=>"red","b"=>"green");
$a2=array("c"=>"blue","b"=>"yellow");
print_r(array_merge($a1,$a2));
?>
Result :
Array ([a]=>red [b]=>yellow [c]=>blue)
As you can see there are two value for key=b. But the result is going to print the 2nd array array as the value.
No comments:
Post a Comment