gilgalbiblewhee
07232008, 02:05 AM
I need to express:
if($i!=){
$i shouldn't be a multiple of 10.
if($i!=){
$i shouldn't be a multiple of 10.


View Full Version : how to avoid multiples of 10? gilgalbiblewhee 07232008, 02:05 AM I need to express: if($i!=){ $i shouldn't be a multiple of 10. oesxyl 07232008, 02:07 AM I need to express: if($i!=){ $i shouldn't be a multiple of 10. if($i % 10 != 0){ regards p4plus2 07232008, 04:23 AM tiny bit more usefull for if you wanna avoid other numbers in the future... <?php function isdiv($number, $divby){ if($number % $divby == 0){ return true; } else{ return false; } } ?> useable for more than one number more than once..... To use simple $numb = isdiv(10, 2); that will set $numb to true. Len Whistler 07232008, 06:49 AM tiny bit more usefull for if you wanna avoid other numbers in the future... I think oesxyl solution is the best. Just replace the 10 with any number and when the remainder = 0 it means that you have reached a multiple of that number. I recommend that the OP study the PHP modulus operator (%), it can be used for all sorts of neat things like alternating row colors, switching banner ads, etc.  FouLu 07232008, 07:40 AM The actual modulus command has some other uses as well, which is why I would also stick with it. PHP has a built in one called fmod for floating notation. I've never used it, but I figure an int typecast would suffice for it. The user notes claim that 1 % 0.2 results in 0.2, but best I remember from computer mathematics that is technically correct for the binary conversion between them. This is the crap that happens when ints are mixed with floats :P 
 
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum