note 105510 added to language.operators.arithmetic
| From: | milespickens+php at gmail dot com | Date: | Tue, 23 Aug 2011 22:00:26 +0000 |
| Subject: | note 105510 added to language.operators.arithmetic | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-182681@lists.php.net to get a copy of this message | ||
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
----
Server IP: 69.147.83.197
Probable Submitter: 174.127.8.233
----
Manual Page -- http://www.php.net/manual/en/language.operators.arithmetic.php
Edit -- https://master.php.net/note/edit/105510
Del: integrated -- https://master.php.net/note/delete/105510/integrated
Del: useless -- https://master.php.net/note/delete/105510/useless
Del: bad code -- https://master.php.net/note/delete/105510/bad+code
Del: spam -- https://master.php.net/note/delete/105510/spam
Del: non-english -- https://master.php.net/note/delete/105510/non-english
Del: in docs -- https://master.php.net/note/delete/105510/in+docs
Del: other reasons-- https://master.php.net/note/delete/105510
Reject -- https://master.php.net/note/reject/105510
Search -- https://master.php.net/manage/user-notes.php