Home >>PHP Math Functions >PHP floor() Function

PHP floor() Function

PHP floor() Function

PHP floor() function is used to round a given input number down to the nearest integer. It accepts only a single parameter $number which is the number you want to round to the nearest integer. It returns the number which represents the $number rounded to the nearest (down) integer.

Syntax:

  floor($number);

Parameter Values

Parameter Description
number This is a required parameter. This parameter defines the value to round down.

Here is an example of floor() function in PHP:

<html>
<body>

<?php

echo floor(0.55)."<br>";
echo floor(1.45)."<br>";
echo floor(1.99)."<br>";

?>

</body>
</html>
Output:
0
1
1

Here is an another example of floor() function in PHP:

<html>
<body>

<?php

echo floor(8)."<br>";
echo floor(8.77)."<br>";
echo floor(-8.777)."<br>";
echo floor(34.001)."<br>";
echo floor(-0.33455)."<br>";

?>

</body>
</html>
Output:
8
8
-9
34
-1