c_shelswell Posted March 7, 2007 Share Posted March 7, 2007 Hi I'm sure this is very easy, my brain is useless at arithmetic I just need to find if a number is a multiple of 3. Just trying to add a by 2 get one free deal so if they've got 3 or 6 etc then i give one free. Cheers Link to comment https://forums.phpfreaks.com/topic/41640-check-if-number-is-a-mulitple-of-3/ Share on other sites More sharing options...
AndyB Posted March 7, 2007 Share Posted March 7, 2007 If it's "buy two get one free" why do you need to know if their selection is divisible by three? Your solution is the modulus operator (%) - http://ca3.php.net/operators.arithmetic Link to comment https://forums.phpfreaks.com/topic/41640-check-if-number-is-a-mulitple-of-3/#findComment-201761 Share on other sites More sharing options...
Jenk Posted March 7, 2007 Share Posted March 7, 2007 If it's "buy two get one free" why do you need to know if their selection is divisible by three? Your solution is the modulus operator (%) - http://ca3.php.net/operators.arithmetic because you don't get one free when you only have two.. Link to comment https://forums.phpfreaks.com/topic/41640-check-if-number-is-a-mulitple-of-3/#findComment-201762 Share on other sites More sharing options...
c_shelswell Posted March 7, 2007 Author Share Posted March 7, 2007 Cheers Andy and yep jenk i was going to check if they had 3 items in their cart i would give one free. I suspect i will check for multiples of 2 if they've bought 5 to let them know they can have another Cheers Link to comment https://forums.phpfreaks.com/topic/41640-check-if-number-is-a-mulitple-of-3/#findComment-201763 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.