3v4l.org

run code in 200+ PHP versions simultaneously
<?php function iterate($current, $queue, $result = null) { if (!$current) { return $result; } return iterate(step($queue), $queue, $current); } function step(&$queue) { return next($queue); } function start($queue) { return current($queue); } function traverse($queue) { return iterate(start($queue), $queue); } $queue = ['foo', 'bar', 'baz']; $queue = unserialize(serialize($queue)); echo traverse($queue); //baz
Output for 5.6.0 - 5.6.29, 7.1.25 - 7.4.0
baz
Output for 7.0.0 - 7.1.0

Process exited with code 137.