Re: Calculating if number is multiple of another number
| From: | Jason Sheets | Date: | Thu, 03 Jul 2003 02:09:11 +0000 |
| Subject: | Re: Calculating if number is multiple of another number | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-153811@lists.php.net to get a copy of this message | ||
Using the modulus operator it returns the remainder of a division operator.
For example to find out if a number is divisible by 3 do this:
if (($number % 3) == 0) {
print $number . ' is divisible by 3';
} else {
print $number . ' is not divisible by 3';
}
If the remainder of dividing the target by the number is 0 then it is a multiple of the number.
jwulff wrote:
How would I calculate if a $number is a multiple of $spacer?