How can you ensure the order of elements when merging values in an array in PHP?

When merging values in an array in PHP, you can ensure the order of elements by using the array_merge function. This function merges two or more arrays together, maintaining the order of elements from left to right. By using array_merge, you can combine arrays while preserving the sequence of values.

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

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

print_r($mergedArray);