Andrew Kreps wrote:
On Tue, 28 Sep 2004 10:45:19 -0700, Jason Davidson <[EMAIL PROTECTED]> wrote:

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) {
       .............


The only thing wrong with this method is that it doesn't fit the
problem's specifications.    The original poster wanted a way to
trigger the code every 20 iterations of an unknown sized loop
(implying that the loop would have 40 or more items), whereas the
solution above only triggers it on iteration 20.  Other than that,
it's a perfectly wonderful piece of code.


You left this line out of Jason's post when you snipped it....

$count = 0;

ie, everytime $count reached 20, run special code, and reset count to $20.

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

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



Reply via email to