3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php // Create an array with 0 value $array = array(0); // Iterate over the array, var_dump each value // At the same time, set the next value to "lolcats" foreach ($array as $key => &$val) { var_dump($val); if($key < 10) { $array[++$key] = "lolcats"; } } // Finally var_dump the $array var_dump($array);
based on 4Y2RH
Output for 7.0.0 - 7.2.0
int(0) string(7) "lolcats" string(7) "lolcats" string(7) "lolcats" string(7) "lolcats" string(7) "lolcats" string(7) "lolcats" string(7) "lolcats" string(7) "lolcats" string(7) "lolcats" string(7) "lolcats" array(11) { [0]=> int(0) [1]=> string(7) "lolcats" [2]=> string(7) "lolcats" [3]=> string(7) "lolcats" [4]=> string(7) "lolcats" [5]=> string(7) "lolcats" [6]=> string(7) "lolcats" [7]=> string(7) "lolcats" [8]=> string(7) "lolcats" [9]=> string(7) "lolcats" [10]=> &string(7) "lolcats" }
Output for 5.3.20 - 5.6.28
int(0) array(2) { [0]=> &int(0) [1]=> string(7) "lolcats" }