3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $blue = array(1,4,7); $red = array(2,3,5,6,8,9); $final_array = array(); for($i=0; $i<sizeof($blue); $i++) { if($i < sizeof($blue)) { $final_array[] = $blue[$i]; } if($i < sizeof($red)) { $final_array[] = $red[$i*2]; $final_array[] = $red[($i*2)+1]; } } echo '<pre>'; print_r($final_array);
Output for 4.3.0 - 7.1.0
<pre>Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 [8] => 9 )