The %= sign is called the Modulus Assignment 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
?>
By the graphical representation:
old value->[17] new value->[3]
variable -> a a
| |
modulus (remainder)
|
17 % 3 = 2
|
The final result assigned in -> a = 2
Output:
2
