3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php echo "without reference\n"; $array = [0, 1, 2]; foreach ($array as $val) { var_dump(current($array)); } unset($array); unset($val); echo "\nwith reference\n"; $array = [0, 1, 2]; foreach ($array as &$val) { var_dump(current($array)); }
based on llSMd
Output for 7.0.28 - 7.3.0rc3
without reference int(0) int(0) int(0) with reference int(0) int(0) int(0)
Output for 5.6.38
without reference int(1) int(1) int(1) with reference int(1) int(2) bool(false)