On Tue, 28 Sep 2004 16:22:18 -0300, Eduardo Sampaio <[EMAIL PROTECTED]> wrote:
> You missed the $count = 0;
> right below it Andrew... his code works just like the modulus one...
Whoops, my mistake. I write code, really I do. :)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe,
Well, elegance, is in the eye of the beholder !!.. but ya, i certainly
wasnt contesting the modulas solutiion, ive used mod in similar cases
myself, i was just adding some variety.
Jason
"Jay Blanchard" <[EMAIL PROTECTED]> wrote:
>
> [snip]
> well, actually, the code resets the count var, so it
Jay Blanchard wrote:
[snip]
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.
[/snip]
That is quite true, but which is more elegant?
Whichever way Martha Stewart wo
[snip]
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.
[/snip]
That is quite true, but which is more elegant?
--
PHP General Mailing List (http://www.php.net/)
T
Hey, im sorry, i didnt read the other responses to your post, ive posted
the same thing...
Jason
"Jason Davidson" <[EMAIL PROTECTED]> wrote:
>
> well, actually, the code resets the count var, so it makes absolutely no
> difference how many iterations the loop makes, it could iterated
> indefin
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 <[EMAIL PROTECTED]> wrote:
>
> On Tue, 28 Sep 2004 10:45:19 -0700, Jason Davidson <[EMAIL PRO
You missed the $count = 0;
right below it Andrew... his code works just like the modulus one...
On Tue, 28 Sep 2004 12:10:21 -0700, Andrew Kreps <[EMAIL PROTECTED]> wrote:
> On Tue, 28 Sep 2004 10:45:19 -0700, Jason Davidson <[EMAIL PROTECTED]> wrote:
> > I see lots of references to modulus, whic
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.. tak
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.
* and then Jason Davidson declared
> 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
* and then Jesse Castro declared
> [snip]
> $count=0;
> foreach($someArray as $someVal) {
> if($count is divisible by 20 exactly) {
> // do some stuff
> }
> //do some stuff
> }
> ?>
> [/snip]
>
> if($count is divisible by 20 exactly)
> Can be written as
> If ($count
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 . {
Nick Wilson wrote:
hi everyone,
I have a simplified bit of code below:
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:
How might i do that?
if($count % 20 == 0 ) {
Janet
--
Janet Valade -- janet.valade.com
--
How might i do that?
Something like that.
Justin
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
* and then Marek Kilimajer declared
> % operator: http://www.php.net/operators
Thanks EVERYONE, i feel like i should have known that, but i didnt, my
thanks! - and the guy that suggested the other way? that was how i was
trying to do it ;-)
--
Nick W
--
PHP General Mailing List (http://w
* and then Pablo Gosse declared
> if ($count%20 == 0)
>
> http://ca3.php.net/manual/en/language.operators.arithmetic.php in the
> manual (look for Modulus).
Yes, thankyou very much, got a bunch of similar replys in my personal
inbox to ;-) And there was me sifting through the math functions!
[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:
How might i do that?
[/snip]
With modulus
...http://us2.php.net/manual/en/language.operators.arithmetic.php
--
PHP General Mailing List (http://www.php.net/
% operator: http://www.php.net/operators
Nick Wilson wrote:
hi everyone,
I have a simplified bit of code below:
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:
How might i do that?
Much thanks...
--
PHP General Ma
[snip]
I have a simplified bit of code below:
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:
[/snip]
if ($count%20 == 0)
http://ca3.php.net/manual/en/language.operators.arithmetic.php in the
manual (look for Mod
Nick Wilson wrote:
hi everyone,
I have a simplified bit of code below:
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:
How might i do that?
Much thanks...
$count = 0;
foreach ( $someArray as $someVal ) {
i
hi everyone,
I have a simplified bit of code below:
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:
How might i do that?
Much thanks...
--
Nick W
--
PHP General Mailing List (http://www.php.net/)
To unsubscr
21 matches
Mail list logo