3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = ['item', '2']; $b = (function () use ($a) { foreach ($a as $item) { yield $item; } })(); while ($b->valid()) { var_dump($b->current()); $b->next(); }

preferences:
46.41 ms | 402 KiB | 5 Q