<?php function arrayProvider() { yield [ 'one', 'two', 'three', ]; yield [ 'four', 'five', 'six', ]; yield [ 'seven', 'eight', 'nine', ]; } function iterateValues(array $array) { foreach ($array as $value) { yield $value; } } function g1() { foreach (arrayProvider() as $array) { $iterator = iterateValues($array); if ($iterator?->valid()) { yield from $iterator; } } } function g2() { yield from g1(); } foreach (g2() as $s) { echo $s . PHP_EOL; }
You have javascript disabled. You will not be able to edit any code.