How can you merge two arrays together in PHP?

To merge two arrays together in PHP, you can use the array_merge() function. This function takes two or more arrays as arguments and returns a new array containing all the elements from the input arrays. The keys are preserved unless two or more arrays have the same key, in which case the later value overrides the previous one.

$array1 = [1, 2, 3];
$array2 = [4, 5, 6];

$mergedArray = array_merge($array1, $array2);

print_r($mergedArray);