3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a = array(1, 2, 3, 4, 5, 6, 7, 8, 9); reset ($a); foreach ($a as $v) { echo('Array points to: ' . current($a) . ' foreach() is at element: ' . $v . "\n"); } echo('After loop array points to: ' . current($a));
based on vYuFG
Output for 4.3.0 - 4.4.0, 4.4.2 - 5.2.3, hhvm-3.10.1 - 3.22.0, 7.0.0 - 7.3.0rc3
Array points to: 1 foreach() is at element: 1 Array points to: 1 foreach() is at element: 2 Array points to: 1 foreach() is at element: 3 Array points to: 1 foreach() is at element: 4 Array points to: 1 foreach() is at element: 5 Array points to: 1 foreach() is at element: 6 Array points to: 1 foreach() is at element: 7 Array points to: 1 foreach() is at element: 8 Array points to: 1 foreach() is at element: 9 After loop array points to: 1
Output for 5.2.4 - 5.6.38
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
Output for 4.4.1
Array points to: 2 foreach() is at element: 1 Array points to: 3 foreach() is at element: 2 Array points to: 4 foreach() is at element: 3 Array points to: 5 foreach() is at element: 4 Array points to: 6 foreach() is at element: 5 Array points to: 7 foreach() is at element: 6 Array points to: 8 foreach() is at element: 7 Array points to: 9 foreach() is at element: 8 Array points to: foreach() is at element: 9 After loop array points to: