3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a = [1, 2, 3, 4, 5, 6, 7, 8, 9]; var_dump($a); foreach ($a as $v) { echo('Array points to: ' . current($a) . ' foreach() is at element: ' . $v . PHP_EOL); } echo('After loop array points to: ' . current($a));
Output for 5.6.19
array(9) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> int(4) [4]=> int(5) [5]=> int(6) [6]=> int(7) [7]=> int(8) [8]=> int(9) } Array points to: 2 foreach() is at element: 1 Array points to: 2 foreach() is at element: 2 Array points to: 2 foreach() is at element: 3 Array points to: 2 foreach() is at element: 4 Array points to: 2 foreach() is at element: 5 Array points to: 2 foreach() is at element: 6 Array points to: 2 foreach() is at element: 7 Array points to: 2 foreach() is at element: 8 Array points to: 2 foreach() is at element: 9 After loop array points to: 2