In PHP arrays can be joined using array union (+) operator or by using array_merge() function. There is a subtle differences in these two methods. The array_merge() function is an inbuilt function for joining two array regardless of their type (numerical, categorical etc.)
array_merge() Function: The array_merge() merges one or more arrays provided as input and provide a new array as output. In this merging process the values of an array is appended to the end of the previous array to generate the resulting array.
array array_merge( $arr1, $arr2, $arr3... )
Parameters: The array_merge() function accepts one or more input array and merges them into single resulting array.
Note: In the array_merge() function if the input arrays have same string keys (in case of categorical arrays) then in the resulting array the later value of the key will overwrite the previous one. But if the array contain numeric keys (in case of numeric arrays) then the values will not be replaced they will simply get appended in the resulting array. Also in case of numeric array the value of the keys will be renumbered starting from zero in the resulting array.
Array union (+) operator: Another way to merge two array is the array union(+) operator. It is a binary operator that means it merges two arrays at a time. The union operator appends the right hand array at the end of the left hand array.
$arr3 = $arr1 + $arr2
Parameters: The union(+) operator works on two arrays at a time and produce the resulting array.
Note: In case of array union(+) operator the keys which are same in both the arrays the values from the left hand array corresponding to the keys will be taken in the resulting array. Also in case of numeric array the index of the right hand array which is same with left hand array will be ignored in resultant array.
Program: PHP code to explain difference between array_merge() and array union(+).
Result of array_merge() funcion Array ( [zero] => 0 [one] => 11 [two] => 2  => 10  => 11  => 12  => 13 [three] => 3 [four] => 4  => 12  => 13  => 14  => 15 ) Result of array union(+) operator Array ( [zero] => 0 [one] => 1 [two] => 2  => 10  => 11  => 12  => 13 [three] => 3 [four] => 4 )