3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $ar = ['a', 'b', 'c', 'd', 'e', 'f']; foreach ($ar as $k => & $v) { echo "$k: $v\n"; if ($v === 'b') array_splice($ar, $k, 1, ['x', 'y']); } echo "\n"; print_r($ar);
Output for 7.0.0 - 7.2.0
0: a 1: b 6: f Array ( [0] => a [1] => x [2] => y [3] => c [4] => d [5] => e [6] => f )
Output for 5.4.2 - 5.6.28
0: a 1: b 0: a 1: x 2: y 3: c 4: d 5: e 6: f Array ( [0] => a [1] => x [2] => y [3] => c [4] => d [5] => e [6] => f )
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/sKF9n on line 2
Process exited with code 255.