PHP Is it possible to skip two or more iterations?

I am aware we can skip the next iteration with continue in a for loop. Anyway to skip the next x loops (2 or more)?


You actually can’t, you can do a dirty trick like

for ($i=0; $i<99; $i++){
    if(someCondition) {
        $i = $i + N; // This will sum N+1 because of the $i++ in the for iterator (that fire when the new loop starts)

Leave a Reply

Your email address will not be published. Required fields are marked *