The addition operation code of PHParray. 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.
The 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 $
Echo "Union of \ $ B and \ $ a: \ n ";
Var_dump ($ c );
?>
Bytes
When executed, this script will print the following:
Union of $ a and $ B:
The 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.
Http://www.bkjia.com/PHPjc/322202.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/322202.htmlTechArticleThe + operator appends elements of remaining keys from the right handed array to the left handed, whereas duplicated keys are NOT overwritten. today again when viewing php manual ,...