让foreach跳过迭代

tma*_*314 11 php

我基本上需要一个foreach循环内的东西,它将跳过数组的前10次迭代.

foreach($aSubs as $aSub){
   if($iStart > '0')
   //Skip first $iStart iterations.  Start at the next one
}
Run Code Online (Sandbox Code Playgroud)

谢谢

Gus*_*Gus 26

启动计数器并使用continue跳过前十个循环:

$counter = 0 ;
foreach($aSubs as $aSub) {
    if($counter++ < 10) continue ;
    // Loop code
}
Run Code Online (Sandbox Code Playgroud)