The + operator appends elements of remaining keys from the right handed array to the left handed, whereas duplicated keys are not overwritten.
I only know this when I read PHP manual again today.
CopyCode The Code is as follows: <? PHP
$ 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 $
Echo "union of \ $ B and \ $ A: \ n ";
Var_dump ($ C );
?>
When executed, this script will 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 $:
Array (3 ){
["A"] =>
String (4) "Pear"
["B"] =>
String (10) "strawberry"
["C"] =>
String (6) "Cherry"
}
It turns out that my understanding is. Directly copy the elements in $ B to $.
I am wrong.