3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $a = array('a', 'b'); foreach ($a as $key => $val) { $a[2] .= 'a'; var_dump($a); } var_dump($a);
based on 5OiHl
Output for 5.3.0 - 7.1.0
Notice: Undefined offset: 2 in /in/o0CZG on line 4 array(3) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(1) "a" } array(3) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(2) "aa" } array(3) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(2) "aa" }
Output for 4.3.0 - 5.2.17
Notice: Undefined offset: 2 in /in/o0CZG on line 4 array(3) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(1) "a" } array(3) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(2) "aa" } array(3) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(2) "aa" }