3v4l.org

run code in 300+ PHP versions simultaneously
<?php function routeIterator(&$path) { while (!empty($path)) { yield $path[0]; array_shift($path); } } function exampleGenerator($path) { foreach ($routeIterator($path) as $chunk) { yield "Chunk: " . $chunk; echo " Sent value: " . yield . "\n"; } } foreach (exampleGenerator([1,2,3,4,5]) as $signal) { echo $signal; }

preferences:
55.14 ms | 402 KiB | 5 Q