Jump to content

Math problem


lanu

Recommended Posts

I'm trying to compare $pastthedate to multiples of 26 - for example 0, 26, 52, etc.. and I have achieved this with the code below:

 

<?php

if ($pastthedate % 26 == 0 || $pastthedate == 0){ ?>

DISPLAY MY CONTENT

<?php } ; ?>

 

Now I also want to display other content if $pastthedate equals multiples of of 26 starting at 1 - for example 1, 27, 53, etc..

and then so on, multiples of of 26 starting at 2 (2, 28, 54, etc..)

and then so on, multiples of of 26 starting at 3 (3, 29, 55, etc..)

"" starting at 4(4, 30, 56, etc..)

"" starting at 5(4, 30, 56, etc..)

all the way up to starting at 25

 

Any help would be greatly appreciated!

 

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/253780-math-problem/
Share on other sites

You're already doing modular division, but you don't seem to know what it's for:

 

 

if ($pastthedate % 26 == 0 ){ ?>

This says "divide the variable by 26, and if the remainder is zero..."  Change the zero to a 1 and you get the exact situation you asked about.

 

Link to comment
https://forums.phpfreaks.com/topic/253780-math-problem/#findComment-1301057
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.