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?
Read the code in the php official manual:
Copy codeThe Code is as follows: $ 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 ).