3v4l.org

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