Freeform Posted June 22, 2007 Share Posted June 22, 2007 Ok, so in php, I have a basic loop, $f counts to 1000. What I am trying to accomplish is an event that is going to take place within the while loop. I would like to skip every fourth count and have that variable = "";. I do not want to accomplish this by using an array simply because it's a sequential pattern that repeats throughout the numbers I need. I have no idea if it's possible, and any help is much appreciated. - Ben Link to comment https://forums.phpfreaks.com/topic/56666-solved-filtering-a-pattern-of-numbers-in-a-loop/ Share on other sites More sharing options...
trq Posted June 22, 2007 Share Posted June 22, 2007 Its a little hard to tell what your after exactly... Something like... <?php for($i = 1;$i <= 1000; $i++) { if (($i % 4) != 0) { echo $i."\n"; } } ?> perhaps? Link to comment https://forums.phpfreaks.com/topic/56666-solved-filtering-a-pattern-of-numbers-in-a-loop/#findComment-279916 Share on other sites More sharing options...
Freeform Posted June 22, 2007 Author Share Posted June 22, 2007 Its a little hard to tell what your after exactly... Something like... <?php for($i = 1;$i <= 1000; $i++) { if (($i % 4) != 0) { echo $i."\n"; } } ?> perhaps? ahh beautiful, yes exactly. What does the % function do? Is it an exemption for ever 4th character, or rather a division/calculating function? Point being that this algorithm is going to go into very large numbers. It's a prime sieve I am working on. - & thank you also. Link to comment https://forums.phpfreaks.com/topic/56666-solved-filtering-a-pattern-of-numbers-in-a-loop/#findComment-279921 Share on other sites More sharing options...
Freeform Posted June 22, 2007 Author Share Posted June 22, 2007 the php modulus function is sweet! Thanx Thorpe. Link to comment https://forums.phpfreaks.com/topic/56666-solved-filtering-a-pattern-of-numbers-in-a-loop/#findComment-280262 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.