3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a = array(1,2,3); $b = &$a; foreach($b as $i => $v) { echo "$i => $v\n"; /*if (isset($b[$i+1])) { $b[$i+1] += 1; }*/ unset($b[$i+1]); } var_dump($a, $b);
based on NYB4s
Output for 7.0.0 - 7.2.0
0 => 1 1 => 2 2 => 3 array(1) { [0]=> int(1) } array(1) { [0]=> int(1) }
Output for 5.3.20 - 5.6.28
0 => 1 2 => 3 array(2) { [0]=> int(1) [2]=> int(3) } array(2) { [0]=> int(1) [2]=> int(3) }