This question already has an answer here:
When I use array_merge()
with associative arrays I get what I want, but when I use them with numerical key arrays the keys get changed.
With +
the keys are preserved but it doesn't work with associative arrays.
I don't understand how this works, can anybody explain it to me?
Because both arrays are numerically-indexed, only the values in the first array will be used.
http://php.net/manual/en/language.operators.array.php
array_merge()
has slightly different behavior:http://php.net/manual/en/function.array-merge.php
These two operation are totally different.
I post the code below to make things clear.