[snip]
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?
[/snip]

With modulus
...http://us2.php.net/manual/en/language.operators.arithmetic.php

<?php
  $count=0;
  foreach($someArray as $someVal) {
    if(0 == ($count % 20)){
      // do some stuff
    }
    //do some stuff
  }
?>

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

Reply via email to