What are some best practices for iterating through multiple arrays and combining them into a single multidimensional array in PHP?

When iterating through multiple arrays and combining them into a single multidimensional array in PHP, it is important to use nested loops to iterate through each array and combine their elements into the final multidimensional array. You can use array_push() or the [] syntax to add elements to the multidimensional array.

$array1 = [1, 2, 3];
$array2 = ['a', 'b', 'c'];
$array3 = ['x', 'y', 'z'];

$combinedArray = [];

foreach ($array1 as $key => $value) {
    $combinedArray[] = [$value, $array2[$key], $array3[$key]];
}

print_r($combinedArray);