round

int round(float num) 

Rounds a floating-point number to the nearest integer.

Returns:

Integer result of rounding

Description:

Rounds a floating-point number up or down to the nearest integer. If the floating-point portion is exactly 0.5, the function rounds up.

Version:

PHP 3, PHP 4

See also:

ceil() 
floor() 

Example:

Round a floating-point number
$number1 = 12.6; 
$number2 = 12.4; 
echo "Number 1: ", round($number1), "\n"; 
echo "Number 2: ", round($number2); 

Get PHP Functions Essential Reference 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.