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; } } var_dump($a, $b);
based on 0BCmi
Output for 7.0.0 - 7.2.0
0 => 1 1 => 2 2 => 3 array(3) { [0]=> int(1) [1]=> int(3) [2]=> int(4) } array(3) { [0]=> int(1) [1]=> int(3) [2]=> int(4) }
Output for 5.3.20 - 5.6.28
0 => 1 1 => 3 2 => 4 array(3) { [0]=> int(1) [1]=> int(3) [2]=> int(4) } array(3) { [0]=> int(1) [1]=> int(3) [2]=> int(4) }