PHP floor() function with example

 15 - Mar - 2022
 XpertPhp
 40

In this article, We will explain to you PHP floor() function with example.

PHP floor() function

The floor() function is a built-in function of PHP. which is used to returns the value of a number rounded DOWNWARDS to the nearest integer. so you can see our PHP math Function example.

Syntax

floor(number,precision,mode);

Example

<?PHP
echo floor(5.8);
echo "
";
echo floor(-5.1);
echo "
";
echo floor(-5.9);
echo "
";
echo floor(0.49);
echo "
";
echo floor(0.50);
?>

Output

5
-6
-6
0
0

Reference: PHP floor() function