RE: [PHP] Loop within Loop help please

From: Date: Tue, 28 Sep 2004 17:26:56 +0000
Subject: RE: [PHP] Loop within Loop help please
Groups: php.general 
Request: Send a blank email to php-general+get-198089@lists.php.net to get a copy of this message
[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 } ?>

« previous php.general (#198089) next »