<?php
$arr1 = [
['A', 'B', 'C'],
['F', 'G']
];
$arr2 = [
['D', 'E'],
['H', 'I', 'J', 'L']
];
foreach ($arr1 as $i => &$row) {
array_push($row, ...$arr2[$i]);
}
var_export($arr1);
- Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
- array (
0 =>
array (
0 => 'A',
1 => 'B',
2 => 'C',
3 => 'D',
4 => 'E',
),
1 =>
array (
0 => 'F',
1 => 'G',
2 => 'H',
3 => 'I',
4 => 'J',
5 => 'L',
),
)
preferences:
52.15 ms | 407 KiB | 5 Q