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 . PHP_EOL); } echo('After loop array points to: ' . current($a));
based on MKipU
Output for 4.3.10 - 4.4.0, 4.4.2 - 4.4.9, 5.0.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.3.0 - 4.3.9, 5.0.0 - 5.0.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/L9mhr on line 6 Array points to: 1 foreach() is at element: 1PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/L9mhr on line 6 Array points to: 1 foreach() is at element: 2PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/L9mhr on line 6 Array points to: 1 foreach() is at element: 3PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/L9mhr on line 6 Array points to: 1 foreach() is at element: 4PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/L9mhr on line 6 Array points to: 1 foreach() is at element: 5PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/L9mhr on line 6 Array points to: 1 foreach() is at element: 6PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/L9mhr on line 6 Array points to: 1 foreach() is at element: 7PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/L9mhr on line 6 Array points to: 1 foreach() is at element: 8PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/L9mhr on line 6 Array points to: 1 foreach() is at element: 9PHP_EOLAfter loop array points to: 1
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: