⊗ppPmBsDR 24 of 447 menu

Modulo Operation in PHP

There is a special operator %, with which you can find the remainder of dividing one number by another:

<?php echo 10 % 3; // outputs 1 ?>

If one number is divisible by the second without a remainder - the result will be zero:

<?php echo 10 % 2; // outputs 0 ?>

The operator % can, of course, be applied not only to numbers but also to variables:

<?php $a = 10; $b = 3; echo $a % $b; // outputs 1 ?>

Given a variable $a with a value of 10 and a variable $b with a value of 3. Find the remainder of dividing $a by $b.

byenru