bcsub
is a function in PHP that subtracts the second argument from the first argument.
Both arguments are arbitrary-precision numbers.
bcsub(string $num1, string $num2, int $scale = null): string
num1
: variable of type string
.
num2
: variable of type string
.
scale
: variable of type int
. This is an optional parameter.
scale
is used to set the number of digits after the decimal place in the result. The default value of scale
is 0.
The bcsub
function returns num2
- num1
.
The function returned is of type
string
.
<?php $num1 = '1.34'; $num2 = '4'; echo bcsub($num1, $num2); echo bcsub($num1, $num2, 2); ?>
3
3.34
RELATED TAGS
CONTRIBUTOR
View all Courses