Monday, June 15, 2026
HomeLanguagesPHP floor() Function

PHP floor() Function

We sometimes need to round down the float values to the next lowest integer in our maths problems. 

PHP provides a built-in function floor() to get this task done through our PHP script. The floor() function in PHP rounds down the float value to the next lowest integer value.

Syntax:

float floor(value)

Parameters: This function accepts the single parameter value which is rounded down to the next lowest integer. 

Return Value: The return type is a float value. It returns the next lowest integer value as a float which is rounded down, only if necessary.

Examples:

Input : floor(1.9)
Output : 1

Input : floor(-1.8)
Output : -2

Input : floor(4)
Output : 4

Note: floor() function is opposite to ceil() function in PHP

Below programs illustrate the floor() function in PHP.

  • When a positive decimal number is passed.

PHP




<?php
    echo floor(2.8);
?>


Output:

2
  • When a negative decimal number is passed.

PHP




<?php
    echo floor(-3.4);
?>


Output:

-4
  • When a number without decimal places is passed.

PHP




<?php
    echo floor(2);
?>


Output:

2

Reference: https://www.php.net/manual/en/function.floor

RELATED ARTICLES

Most Popular

Dominic
32516 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6897 POSTS0 COMMENTS
Nicole Veronica
12013 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6964 POSTS0 COMMENTS