round
round — Rounds a float.Description
round( int|float $num, int $precision = 0, int $mode = PHP_ROUND_HALF_UP ): floatReturns the rounded value of num to specified precision (number of digits after the decimal point). precision can also be negative or zero (default).
Parameters
num
The value to round.
characters
The optional number of decimal digits to round to.
If the precision is positive, num is rounded to precision significant digits after the decimal point.
If the precision is negative, num is rounded to precision significant digits before the decimal point, i.e. to the nearest multiple of pow(10, -precision), e.g. for a precision of -1 num is rounded to tens, for a precision of -2 to hundreds, etc.
If the precision is positive, num is rounded to precision significant digits after the decimal point.
If the precision is negative, num is rounded to precision significant digits before the decimal point, i.e. to the nearest multiple of pow(10, -precision), e.g. for a precision of -1 num is rounded to tens, for a precision of -2 to hundreds, etc.
mode
Use one of the following constants to specify the mode in which rounding occurs.
Return Values
The value rounded to the given precision as a float.More information about round on official PHP documentation site
round - Popular snippets
- PHP 8.0 / MySQL 5.7 round memory_get_usage
last run:
2023-01-06 10:59:18
110
- PHP 8.0 / MySQL 5.7 round memory_get_usage str_repeat round memory_get_usage str_repeat
last run:
2021-04-20 15:37:57
21
- PHP 7.4 / MySQL 5.7 microtime round
last run:
2022-03-10 19:44:01
19
- PHP 8.0 / MySQL 5.7 mt_rand mt_getrandmax round
last run:
2021-10-20 17:39:04
14
- PHP 7.4 / MySQL 5.7 microtime round
last run:
2021-04-14 08:39:38
9
- PHP 7.4 / MySQL 5.7 microtime round count var_dump
last run:
2021-04-14 10:35:54
9
- PHP 7.4 / MySQL 5.7 round memory_get_usage str_repeat
last run:
2021-04-10 15:11:42
9
- PHP 7.4 / MySQL 5.7 round memory_get_usage
last run:
2021-04-10 15:11:58
9
- PHP 7.4 / MySQL 5.7 microtime preg_replace round var_dump array_sum
last run:
2021-05-02 15:53:46
8
round - New snippets
-
PHP 8.1 / MySQL 5.7 count round var_dump
added at:
2023-03-09 19:45:04
1
-
PHP 8.1 / MySQL 5.7 count round var_dump
added at:
2023-03-09 19:45:00
1
-
PHP 8.0 / MySQL 5.7 mt_rand mt_getrandmax round
added at:
2023-01-27 08:44:19
1
-
PHP 8.1 / MySQL 5.7 abs round
added at:
2022-12-24 08:49:16
1
-
PHP 8.1 / MySQL 5.7 abs round
added at:
2022-12-24 08:49:02
1
-
PHP 8.1 / MySQL 5.7 time explode microtime round sleep
added at:
2022-12-17 23:37:23
1
-
PHP 8.1 / MySQL 5.7 number_format time explode microtime round sleep
added at:
2022-12-17 23:35:36
1
-
PHP 8.1 / MySQL 5.7 time number_format explode microtime round sleep
added at:
2022-12-17 23:34:57
1
-
PHP 8.1 / MySQL 5.7 time number_format explode microtime round sleep
added at:
2022-12-17 23:34:50
1
-
PHP 8.1 / MySQL 5.7 time number_format explode microtime round sleep
added at:
2022-12-17 23:32:33
2