I ran the following code, to test if a number was divisible by 7 and then return only if true.
is_int gives me what I think, but using modulus to check if it is an integer (%1) I get floats too.
for ($i = 100; $i < 222; $i++) {
$dividedBy7 = $i/7;
if(is_int($dividedBy7)){
echo 'is int thinks '.$dividedBy7.'</br>';
}
if($dividedBy7 % 1 == 0){
echo 'modulus thinks '.$dividedBy7.'</br>';
}
}
OUTPUT
modulus thinks 14.2857142857, modulus thinks 14.4285714286 etc
is int thinks15, 16 etc
What is wrong with my understanding of modulus?
EDIT I appreciate that %7 is the correct use of modulus in this example, but this is a simplification of the situation.