Jump to content

[SOLVED] Divisions of 5


schme16

Recommended Posts

if ($x % 5 == 0 ) {
  // Do your stuff
}

 

I agree that the modulous operator is what you're after. You can compare like that, or you can simply loop through and keep a counter to do something every 5 repetitions:

<?php
for ($i = 1; $i <= 150; $i++) {
  if ($i % 5 == 0) {
    echo "Fifth repetition<br />\n";
  } else {
    echo "...<br />\n";
  }
}
?>

 

Have fun!

Link to comment
https://forums.phpfreaks.com/topic/47225-solved-divisions-of-5/#findComment-230310
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.