PHP function round()
Availability in PHP 4.0
Returns the rounded value of val to specified precision (number of digits after the decimal point). precision can also be negative or zero (default). Note: PHP doesn't handle strings like "12,300.2" correctly by default. See converting from strings.
Parameters
| Parameter | Data type | Default value | Note |
|---|---|---|---|
$val |
float |
not | The value to round |
$precision |
int |
0, | The optional number of decimal digits to round to. |
$mode |
int |
PHP_ROUND_HALF_UP | One of PHP_ROUND_HALF_UP, PHP_ROUND_HALF_DOWN, PHP_ROUND_HALF_EVEN, or PHP_ROUND_HALF_ODD. |
Return values
float
The rounded value