PHP floor()

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.

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours

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`:

Code
Output

All contributors

Contribute to Docs

Learn PHP on Codecademy

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours