Jump to content

counting troubles


lanu

Recommended Posts

Hi there,

My code here is meant to take the variable "$beyondportal" and see if it is a multiple of 26 counting from 0, then from 1, 2, 3 etc.. all the way to 25.

if it's a multiple of 26 counting from 1, I get a set of content. If it's a multiple of 26 counting from 1, I get another all the way through 25.

The code I wrote is working great if $beyond portal turns out to be a positive value, but if it's a negative value, this seems to be coming up wrong except for in the case of

multiples of 26 counting up from 0 because -26 is the same distance as 26 from zero.

Can someone see the pattern I'm getting at here?

 

 

 

<?php if ($beyondportal % 26 == 0 || $beyondportal == 0 || abs($beyondportal) % 26 == 0){ ?>

PURPLE

<?php } ; ?>

 

<?php if ($beyondportal % 26 == 1 || $beyondportal == 1|| abs($beyondportal) % 26 ==1){ ?>

BLUE

<?php } ; ?>

 

<?php if ($beyondportal % 26 == 2 || $beyondportal == 2|| abs($beyondportal) % 26 ==2){ ?>

GREEN

<?php } ; ?>

 

ETC... ETC.... up to:

 

<?php if ($beyondportal % 26 == 25 || $beyondportal == 25|| abs($beyondportal) % 26 ==25){ ?>

YELLOW

<?php } ; ?>

 

(my code on 1-25 is coming up incorrectly)

Link to comment
Share on other sites

change

<?php if ($beyondportal % 26 == 0 || $beyondportal == 0 || abs($beyondportal) % 26 == 0){ ?>
PURPLE    
<?php } ; ?>

to

<?php if ($beyondportal % 26 == 0){ ?>
PURPLE    
<?php } ; ?>

or

<?php if (abs($beyondportal) % 26 == 0){ ?>
PURPLE    
<?php } ; ?>

for all sace

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.