Account
Categories

Modulus AND Assign Operator


The %= sign is called the Modulus AND Assign Operator.

It takes the value on the left, divides it by the value on the right, and saves the remainder in the same variable.

The value on the right side is being input into the variable on the left side.

Syntax:
$variable %= value;
Example:
<?php
$x = 17;
$x %= 3; // remainder of $x divided by 3, now $x is 2
?>
Output:
2