Re: Loop within Loop help please

From: Date: Tue, 28 Sep 2004 20:04:47 +0000
Subject: Re: Loop within Loop help please
Groups: php.general 
Request: Send a blank email to php-general+get-198114@lists.php.net to get a copy of this message
well, actually, the code resets the count var, so it makes absolutely no difference how many iterations the loop makes, it could iterated indefinately and still function identically. Jason Andrew Kreps <andrew.kreps@gmail.com> wrote: > > On Tue, 28 Sep 2004 10:45:19 -0700, Jason Davidson <jdavidson@zworg.com> 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. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#198114) next »