tmartin314 tmartin314 - 1 year ago 130
PHP Question

Getting foreach to skip over iterations

I basically need something inside a foreach loop that will skip over the first 10 iterations of the array.

foreach($aSubs as $aSub){
if($iStart > '0')
//Skip first $iStart iterations. Start at the next one


Gus Gus
Answer Source

Start a counter and use continue to skip the first ten loops:

$counter = 0 ;
foreach($aSubs as $aSub) {
    if($counter++ < 10) continue ;
    // Loop code
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download