PHP Manual

PHP function round()

2019-09-11T08:04:03.000Z

Obsah článku

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

Other resources

Official documentation of the round function

Jan Barášek   Více o autorovi

Autor článku pracuje jako seniorní vývojář a software architekt v Praze. Navrhuje a spravuje velké webové aplikace, které znáte a používáte. Od roku 2009 nabral bohaté zkušenosti, které tímto webem předává dál.

Rád vám pomůžu:

Související články

1.
16.

V jiných jazycích

Status:
All systems normal.
2025