3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a = ['foo','bar','baz']; // touch refcount $b = &$a; foreach($a as $v) { echo 'Running ', $v, "\n"; unset($a[1]); var_dump($a); } echo 'final:', "\n"; var_dump($a);
based on 8ZWHa
Output for 7.0.0 - 7.2.0
Running foo array(2) { [0]=> string(3) "foo" [2]=> string(3) "baz" } Running bar array(2) { [0]=> string(3) "foo" [2]=> string(3) "baz" } Running baz array(2) { [0]=> string(3) "foo" [2]=> string(3) "baz" } final: array(2) { [0]=> string(3) "foo" [2]=> string(3) "baz" }
Output for 5.4.11 - 5.6.28
Running foo array(2) { [0]=> string(3) "foo" [2]=> string(3) "baz" } Running baz array(2) { [0]=> string(3) "foo" [2]=> string(3) "baz" } final: array(2) { [0]=> string(3) "foo" [2]=> string(3) "baz" }
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/eSGZ9 on line 3
Process exited with code 255.