PHP floor() Function

Definition and Usage

The floor() function rounds down to the nearest integer.

Syntax

floor(x)
Parameter Description
x Required. A number.

Description

return not greater than x The next integer, will x The decimal part is discarded and rounded down. The type returned by floor() is still float because the range of float values is usually larger than that of integers.

Example

In this example, we will apply the floor() function to different numbers:

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

Output:

0
0
5
5
-6
-6