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 the Code code 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 the Code code 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.
The above describes the ArrayList sort PHP array addition operation code, including the content of ArrayList sorting, I hope that the PHP tutorial interested in a friend helpful.