← All built-ins / round()
round()
round(...$args): mixed
Parameters
| Name | Type | Description |
|---|---|---|
| $num | float|int | number to round |
| $precision | int | decimal places (default 0)optional |
| $mode | int | PHP_ROUND_HALF_UP (default), _HALF_DOWN, _HALF_EVEN, _HALF_ODDoptional |
Return value
The rounded number.
Example
echo round(3.14159, 2), " ", round(2.5), " ", round(3.5), " ", round(2.5, 0, PHP_ROUND_HALF_EVEN);
3.14 3 4 2