How To Array Merge In PHP?

This article will give you simple two example of array merge in php.

1. Code:

<?php
function arrayMerge($array1, $array2){
	$array = array_merge($array1, $array2);
    return $array;
} 
   $array1 = [ 
    'sol1' => 'soltuts',
    'sol2' => 'tutorials',
];
$array2 = [ 
    'sol3' => 'tips',
    'sol4' => 'tricks ',
];

print_r(arrayMerge($array1, $array2));
?>

2. Example:

Input:

 $array1 = [ 
    'sol1' => 'soltuts',
    'sol2' => 'tutorials',
];
$array2 = [ 
    'sol3' => 'tips',
    'sol4' => 'tricks ',
];

Output:

Array ( 
[sol1] => soltuts 
[sol2] => tutorials 
[sol3] => tips 
[sol4] => tricks )