math

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
theclay7
Forum Commoner
Posts: 50
Joined: Wed Feb 19, 2003 3:17 am

math

Post by theclay7 »

if I have a variable $check20Multi

and I want to check if $check20Multi falls in the multiple of 20, that is, check if it is 20, 40, 60, 80 .... 2000

how can I do it....

because I want to do the following:

if $check20Multi is equal to A Multiple of 20

then $totalpage = $totalpage + 1;
User avatar
trollll
Forum Contributor
Posts: 181
Joined: Tue Jun 10, 2003 11:56 pm
Location: Round Rock, TX
Contact:

You want the modulus

Post by trollll »

if ($check20Multi%20==0) {
$totalpage = $totalpage + 1;
}

//

if $check20Multi = 42, then $check20Multi%20 = 2
"%" gives you the remainder of $check20Multi/42

check out the arithmetic operators:
http://www.php.net/manual/en/language.o ... hmetic.php
Post Reply