Name

round

Synopsis

float round(float number[, int precision[, int mode]])

Returns the integer value nearest to number at the precision number of decimal places. The default for precision is 0 (integer rounding). The mode parameter dictates the method of rounding used:

PHP_ROUND_HALF_UP (default)

Round up

PHP_ROUND_HALF_DOWN

Round down

PHP_ROUND_HALF_EVEN

Round up if the significant digits are even

PHP_ROUND_HALF_ODD

Round down if the significant digits are odd

Get Programming PHP, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.