I see lots of references to modulus, which works fantastic.. but how
abut just testing if its equal to 20, then there isnt that extra
arthmitc call.. this is just another way to do the same thing.. take
your pick.. unless someone can see a bad reason for this method. 

$count = 0;
foreach ..... {
   if($count == 20) {
        .............
        $count = 0;
    } else {
        $count++;
    }
}


Nick Wilson <[EMAIL PROTECTED]> wrote: 
> 
> hi everyone, 
> 
> I have a simplified bit of code below:
> <?php
>   foreach($someArray as $someVal) {
>     //do some stuff
>   }
> ?>
> 
> What i'd like to do is have a count inside that loop that will trigger
> some action every 20 iterations of the foreach. Like this:
> <?php
>   $count=0;
>   foreach($someArray as $someVal) {
>     if($count is divisible by 20 exactly) {
>       // do some stuff
>     }
>     //do some stuff
>   }
> ?>
> 
> How might i do that?
> 
> Much thanks...
> -- 
> Nick W
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to