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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.