See a problem on the Internet:
The result of Array ("a") +array ("B") is ___
A.array ("A", "B")
B.array ("B", "a")
C.array ("B")
D.array ("a")
Answer: D
PHP two arrays added, why the result is still the same?
Because they are equivalent to array ("0″=>") +array ("0″=>"), they have the same key name, which cannot be overwritten by the latter, if it is array ("0″=>" a ") +array (" 0″=> "B", "1″= > "C"), the result equals array ("0″=>" a "," 1″=> "C")
What happens if you have the same key name in the same array?
Read the code in the official PHP manual:
Copy Code code as follows:
$switching = Array (ten,//key = 0
5 => 6,
3 => 7,
' A ' => 4,
One,//key = 6 (maximum of integer-indices was 5)
' 8 ' => 2,//key = 8 (integer!)
' => ',//key = ' 02 '
0 =>//The value of is overwritten by 12
);
Thus, if the same key is in the same array, the value of the previous key name will be overwritten (overwritten).