How to Join Two Arrays in PHP using array_merge Function

In PHP array_merge() function is used to merge two or more arrays together.

Example : use array_merge function two merge two arrays in PHP

In This Example we have two PHP arrays, $color1 and $color2. And we Combined $color1 and $color2 using php array_merge function.

Array ( [0] => Red [1] => Green [2] => Blue [3] => White [4] => Black ) 

Example 2

Array ( [country1] => Canada [country2] => UK [country3] => France [country4] => Spain [country5] => China ) 

In the above Example we join three PHP arrays together. Also notice that both $array_one and array_two have the same array key country1. So when PHP joins three arrays together country1 key of the array_two will override the country1 key of the $array_one.