3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $workTimeRange = [ ['time'=>600], ['time'=>900], ['time'=>3600], ['time'=>4000], ]; $arrWorkRange = []; for ($i = 0; $i < count($workTimeRange); $i+=2) { echo $i.PHP_EOL; array_push($arrWorkRange, [ 'start_time' => $workTimeRange[$i]['time'], 'end_time' => $workTimeRange[$i+1]['time'], ]); print_r($arrWorkRange); } print_R($arrWorkRange); for($i=0;$i<count($workTimeRange);$i+=2){ echo $i.PHP_EOL; }
based on NRv0u
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.22.0, 7.1.0 - 7.3.0rc3
0 Array ( [0] => Array ( [start_time] => 600 [end_time] => 900 ) ) 2 Array ( [0] => Array ( [start_time] => 600 [end_time] => 900 ) [1] => Array ( [start_time] => 3600 [end_time] => 4000 ) ) Array ( [0] => Array ( [start_time] => 600 [end_time] => 900 ) [1] => Array ( [start_time] => 3600 [end_time] => 4000 ) ) 0 2