3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array1 = array(array(77, 87), array(23, 45)); $array2 = array("w3resource", "com"); function merge_arrays_by_index($x, $y) { $temp = array(); $temp[] = $x; if(is_scalar($y)) { $temp[] = $y; } else { foreach($y as $k => $v) { $temp[] = $v; } } return $temp; } print_r($array1); print_r($array2); ?>
based on Yce65
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Array ( [0] => Array ( [0] => 77 [1] => 87 ) [1] => Array ( [0] => 23 [1] => 45 ) ) Array ( [0] => w3resource [1] => com )