X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

PHP floor() Function

PHP Math Reference PHP Math Reference

Example

Round numbers down to the nearest integer:

<?php
echo(floor(0.60) . "<br>");
echo(floor(0.40) . "<br>");
echo(floor(5) . "<br>");
echo(floor(5.1) . "<br>");
echo(floor(-5.1) . "<br>");
echo(floor(-5.9));
?>

Run example »

Definition and Usage

The floor() function rounds a number DOWN to the nearest integer, if necessary.

Tip: To round a number UP to the nearest integer, look at the ceil() function.

Tip: To round a floating-point number, look at the round() function.


Syntax

floor(number);

Parameter Description
number Required. Specifies the value to round down

Technical Details

Return Value: The value rounded down to the nearest integer
Return Type: Float
PHP Version: 4+


PHP Math Reference PHP Math Reference

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook