<?php $generator = (function() { $count = 3; echo "Start\n"; while(true) { yield; // suspend the function (the generator) echo "Are there results?\n"; $count--; if ($count === 0) { return; // We received the results, we stop } } })(); $generator->current(); // Initiates processing do { echo "Do something else\n"; $generator->next(); // Restart the function (resume at "yield") } while ($generator->valid()); // Has the function finished? echo "End\n";
You have javascript disabled. You will not be able to edit any code.
Value for `_results` contains invalid data `array`