3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = [ [10, 'Some Name..'], [11, 'Some Name..'], [13, 'Some Name..'], ]; $array2 = [ [13, 'Viewed'] ]; $result = []; foreach (array_merge($array1, $array2) as [$id, $value]) { $result[$id][0] = $id; $result[$id][] = $value; } var_export($result);
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
array ( 10 => array ( 0 => 10, 1 => 'Some Name..', ), 11 => array ( 0 => 11, 1 => 'Some Name..', ), 13 => array ( 0 => 13, 1 => 'Some Name..', 2 => 'Viewed', ), )

preferences:
78.53 ms | 1138 KiB | 4 Q