<?php function rotate(iterable $iterable, callable $predicate) { $tail = []; $match = false; foreach ($iterable as $key => $value) { if ($match || $predicate($value)) { yield $key => $value; $match = true; } else { $tail[] = [$key, $value]; } } foreach ($tail as [$key, $value]) { yield $key => $value; } } function gen() { yield 1; yield 2; yield 3; yield 4; yield 5; } $res = rotate(gen(), function($el) { return $el === 3; }); var_dump(iterator_to_array($res)); // [3, 4, 5, 1, 2]
You have javascript disabled. You will not be able to edit any code.
Value for `_results` contains invalid data `array`