Page 1 of 1

math

Posted: Tue Jun 10, 2003 10:56 pm
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;

You want the modulus

Posted: Tue Jun 10, 2003 11:56 pm
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