Jump to content

Help with modulus operator


scarhand

Recommended Posts

I want to use a conditional statement that adds a line break every 15 posts.

 

Example:

 

post 1
post 2
post 3
post 4
post 5
post 6
post 7
post 8
post 9
post 10
post 11
post 12
post 13
post 14
post 15
<br /> <- added via modulus or w/e
post 16
post 17
post 18
post 19
post 20
post 21
post 22
post 23
post 24
post 25
post 26
post 27
post 28
post 29
post 30
<br /> <- added via modulus or w/e
post 31
post 32

 

I've tried using:

 

If ($postcount % 15)
  echo '<br />';

 

Maybe I'm not totally grasping the operator. Could someone tell me the proper way to accomplish this?

Link to comment
https://forums.phpfreaks.com/topic/197714-help-with-modulus-operator/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.