3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $array = [0, 1, 2]; $ref =& $array; // Necessary to trigger the old behavior foreach ($array as $val) { var_dump($val); $array[1] = 'X'; } var_dump($ref);
based on AIdoM
Output for 7.0.0 - 7.2.0
int(0) int(1) int(2) array(3) { [0]=> int(0) [1]=> string(1) "X" [2]=> int(2) }
Output for 5.4.2 - 5.6.28
int(0) string(1) "X" int(2) array(3) { [0]=> int(0) [1]=> string(1) "X" [2]=> int(2) }
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/eYYXK on line 3
Process exited with code 255.