Account
Categories

Subtract And Assign Operator


The -= sign is called the Subtract AND Assign Operator.

It takes the value on the left, subtracts the value on the right, and saves the result 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 = 15;
$x -= 5; // subtracts 5 from $x, now $x is 10
?>
Output:
10