if count == 5, 9, 13, 17, 21 etc etc echo....

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
awelch
Forum Newbie
Posts: 3
Joined: Wed Nov 18, 2009 7:55 am

if count == 5, 9, 13, 17, 21 etc etc echo....

Post by awelch »

I have a count (of wordpress posts)

if the count of posts equals 5, 9, 13, 17, 21 etc then I want to write some css

Any ideas how to check if the count is the above numbers without doing a switch statement- e.g. is there a way to tell that number sequence?

for example:-

if (($count == 1) {echo " no-margin-left";}
if (($count % 4) == 0) {echo " no-margin-right ";}

and then I want

if count equals 5, 9, 13, 17, 21, etc etc etc then echo " clear-left no-margin-left ";

thanks in advance

andy
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: if count == 5, 9, 13, 17, 21 etc etc echo....

Post by mikosiko »

(($count - 1) % 4 == 0) maybe?
Post Reply