- range: documentation ( source)
<?php
function test() {
$test = range(0, 10);
foreach ($test as $int) {
echo 'before' . PHP_EOL;
yield $int;
echo 'after' . PHP_EOL;
}
}
$test = test();
echo $test->current() . PHP_EOL;
$test->next();
echo $test->current() . PHP_EOL;
$test->next();
$test->next();
$test->previous();