3v4l.org

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