note 105510 deleted from language.operators.arithmetic by hholzgra
| From: | hholzgra@php.net | Date: | Thu, 02 Aug 2012 15:08:24 +0000 |
| Subject: | note 105510 deleted from language.operators.arithmetic by hholzgra | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-189827@lists.php.net to get a copy of this message | ||
Note Submitter: milespickens+php at gmail dot com
----
I have found a simple way to test if a number is divisible by another.
<?php
for ($x=0; $x<14; $x++) {
$num = $x/3; //if $x is NOT divisible, $num will be a float
if (is_int($num)) {
echo $x . ' is divisible by 3 <br />';
}
}
?>
This would output:
3 is divisible by 3
6 is divisible by 3
9 is divisible by 3
12 is divisible by 3