The + operator appends elements of remaining keys from the right handed array to the left handed, whereas duplicated keys is not overwritten.
Today I see PHP manual again, only to know
Copy CodeThe code is as follows:
$a = Array ("A" = "Apple", "b" = "banana");
$b = Array ("A" = "pear", "b" = "Strawberry", "c" = "cherry");
$c = $a + $b; Union of $a and $b
echo "Union of \ $a and \ $b: \ n";
Var_dump ($c);
$c = $b + $a; Union of $b and $a
echo "Union of \ $b and \ $a: \ n";
Var_dump ($c);
?>
When executed, this script would print the following:
Union of $a and $b:
Copy CodeThe code is as follows:
Array (3) {
["A"]=>
String (5) "Apple"
["B"]=>
String (6) "Banana"
["C"]=>
String (6) "Cherry"
}
Union of $b and $a:
Array (3) {
["A"]=>
String (4) "Pear"
["B"]=>
String (Ten) "Strawberry"
["C"]=>
String (6) "Cherry"
}
Originally, my understanding is. Directly copy the elements in the $b directly into $ A.
I was wrong.
http://www.bkjia.com/PHPjc/322202.html www.bkjia.com true http://www.bkjia.com/PHPjc/322202.html techarticle the + operator appends elements of remaining keys from the right handed array to the left handed, whereas duplicated K Eys is not overwritten. Today, when I look at PHP manual again, ...