lanu Posted December 24, 2011 Share Posted December 24, 2011 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! Quote Link to comment https://forums.phpfreaks.com/topic/253780-math-problem/ Share on other sites More sharing options...
ManiacDan Posted December 24, 2011 Share Posted December 24, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/253780-math-problem/#findComment-1301057 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.