Merging two or more arrays
Using an built-in function array_merge() we can merge two or more arrays to form a single array. The values from the second array are appended at the end of first array and so on. So, if three arrays are to be merged, elements from third will be appended at the end of second array and then it will be appended at the end of the first array. Take a look at this syntax and example:
array_merge ( array array1 [, array array2 [, array ...]] )
PHP Code:
<?
$first_array = array(1,2);
$second_array = array(3,4);
$third_array = array(5,6);
$merged_array = array_merge($first_array,$second_array,$third_array);
print_r($merged_array);
//Output: Array
// ( [0] => 1
// [1] => 2
// [2] => 3
// [3] => 4
// [4] => 5
// [5] => 6
// )
?>