MarkM Posted January 31, 2012 Share Posted January 31, 2012 Hello everyone, I'll try to explain this the best I can.. I'm trying to figure out how to echo out a statement when $i is equal to 3,6,9,12,ect. ( up by three) poor example if ($i == 3,6,9,12,ect) echo 'this'; }else{ echo 'no'; } Thanks for you help. Link to comment https://forums.phpfreaks.com/topic/256113-every-time-i-x3/ Share on other sites More sharing options...
AyKay47 Posted January 31, 2012 Share Posted January 31, 2012 use the modulus operator: if ($i % 3 == 0) echo 'this'; }else{ echo 'no'; } http://php.net/manual/en/language.operators.arithmetic.php Link to comment https://forums.phpfreaks.com/topic/256113-every-time-i-x3/#findComment-1312926 Share on other sites More sharing options...
MarkM Posted January 31, 2012 Author Share Posted January 31, 2012 Awesome Thanks AyKay47! Link to comment https://forums.phpfreaks.com/topic/256113-every-time-i-x3/#findComment-1312933 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.