You can see a question on the Internet:
The result of Array ("A") + array ("B") is ___
A. Array ("A", "B ")
B. Array ("B", "")
C. Array ("B ")
D. Array ("")
Answer: d
Why does the result remain unchanged when the PHP arrays are added?
Because they are equivalent to array ("0" => "A") + array ("0" => "B"), they have the same key name, the former cannot be overwritten by the latter. If it is array ("0" => "A") + array ("0" => "B ", "1" => "C"), then the result is equal to array ("0" => "A", "1" => "C ")
What happens if the same key name exists in the same array?
Refer to the official PHP manual.Code:
$ Switching = array (10, // key = 0 5 => 6, 3 => 7, 'A' => 4, 11, // key = 6 (maximum of integer-indices was 5) '8' => 2, // key = 8 (integer !) '02' => 77, // key = '02' 0 => 12 // The value 10 will be overwritten by 12 );
It can be seen that if the same key name exists in the same array, the value of the previous key name will be overwritten ).
(This article original from small talk blog: http://tanteng.sinaapp.com/2012/09/array-a-b)