Account
Categories

Modulus Operator


You use the modulus operator (%) in a webpage for mathematical calculation. It helps in finding the remainder of two values (numbers), which are also called operands, and together with the percent sign (%) they perform the modulus operation.

Syntax:

$result = $left_operand % $right_operand;

Example:

<?php
$a = 10;
$b = 3;
$mod = $a % $b;
echo "The modulus is: ". $mod;
?>

Output:

The modulus is: 1