3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $arr = array(1,2,3,4,5,6,7,8,9); foreach($arr as $key=>$value) { unset($arr[$key + 1]); echo $value . PHP_EOL; } var_dump($arr); echo '#######################'. PHP_EOL; $arr = array(1,2,3,4,5,6,7,8,9); while (list($key, $value) = each($arr)) { unset($arr[$key + 1]); echo $value . PHP_EOL; } var_dump($arr);
Output for 7.2.0
1 2 3 4 5 6 7 8 9 array(1) { [0]=> int(1) } ####################### Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /in/FB1Rl on line 17 1 3 5 7 9 array(5) { [0]=> int(1) [2]=> int(3) [4]=> int(5) [6]=> int(7) [8]=> int(9) }
Output for 5.3.21 - 7.1.10
1 2 3 4 5 6 7 8 9 array(1) { [0]=> int(1) } ####################### 1 3 5 7 9 array(5) { [0]=> int(1) [2]=> int(3) [4]=> int(5) [6]=> int(7) [8]=> int(9) }