PHP是否可以跳过两个或多个迭代?

gio*_*o79 3 php for-loop continue

我知道我们可以在for循环中继续执行,从而跳过下一个迭代。无论如何要跳过下一个x循环(2个或更多)?

Gum*_*aro 5

你实际上不能,你可以做一个肮脏的把戏

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)
        continue;
    }
}
Run Code Online (Sandbox Code Playgroud)