3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a = [1, 2, 3, 4, 5, 6, 7, 8, 9]; 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 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.4.0 - 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.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/i7qha on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/i7qha on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/i7qha on line 3
Process exited with code 255.