how to force foreach reset in php
You could do something around these lines (and avoid the limitations of recursion):
while (True) {
$reset = False;
foreach ($rows as $row) {
if(something true) {
continue;
} else {
$reset = True;
break;
}
}
if ( ! $reset ) {
break; # break out of the while(true)
}
# otherwise the foreach loop is `reset`
}
It seems that reset
inside a foreach
has no effect.
You can implement this if you make your own Traversable
.