3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $array = [1,2,3]; foreach($array as &$val) { echo $val, PHP_EOL; foreach ($array as &$val2) { unset($array[1]); echo $val, PHP_EOL; } } $array = array(1,2,3); foreach( $array as &$item ) { } print_r( $array ); foreach( $array as $item ) { } print_r( $array );
based on 1V6f1
Output for 7.0.0 - 7.2.0
1 1 1 3 3 3 Array ( [0] => 1 [1] => 2 [2] => 3 ) Array ( [0] => 1 [1] => 2 [2] => 2 )
Output for 5.4.10 - 5.6.28
1 1 1 Array ( [0] => 1 [1] => 2 [2] => 3 ) Array ( [0] => 1 [1] => 2 [2] => 2 )
Output for 5.3.20 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/3paSI on line 3
Process exited with code 255.