Answer the question
In order to leave comments, you need to log in
Similar to next in PHP generators?
function g() {
yield 1;
yield 2;
}
$val = g();
// как получить 1, а потом 2
// наподобие next() в javascript ?
// или в php можно только переберать через foreach ?
Answer the question
In order to leave comments, you need to log in
<?php
$generator = (function (): \Generator {
yield 1;
yield 2;
})()
var_dump($generator->current());
$generator->next();
var_dump($generator->current());
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question