The modulus operator returns the remainder of the division of the first operand by the second. For example, 4 % 3 returns 1, 17 % 3 returns 2, etc. If the the second operand is a multiple of the first, then the remainder will obviously be 0, which is what we're checkign for there.
$x % $y finds the remainder of $x divided by $y. By checking if the remainder is equal to 0—which is what the "== 0" does—checks that there's no remainder left over, which is what happens when $x is divisible by $y.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.