floor()

Anonymous contributor's avatar
Anonymous contributor
Anonymous contributor's avatar
Anonymous contributor
Published May 26, 2023
Contribute to Docs

The floor() function returns a rounded number down to the nearest integer.

The result returns a value type of float.

Syntax

$result = floor(n);

Where n is the number to be rounded down to the nearest integer.

Example

floor(3.4)
// Output: 3

The result will be a float value of 3 as the function rounds 3.4 down to 3.

Codebyte Example

Using floor() to return the value of 5 after rounding down`:

us
Visit us
code
Hide code
Code
Output
Hide output
Hide output
Loading...

All contributors

Looking to contribute?

Learn PHP on Codecademy