PHP floor

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

PHP : floor() function

Description

The floor() function is used to convert a given numeric value to the next lowest integer value by rounding (if necessary).

Version

(PHP 4 and above)

Syntax

floor(num)

Parameter

Name

Description

Required /
Optional

Type

num

Any numeric value.

Required

Float

Return value

Rounded number.

Value Type : Float.

Pictorial Presentation

php math floor() function

Example :

  1. $val1=10;  

  2. $val2=-111.13;  

  3. $val3=100.01;  

  4. $val4=-200;  

  5. $zflr1=floor($val1);  

  6. $zflr2=floor($val2);  

  7. $zflr3=floor($val3);  

  8. $zflr4=floor($val4);  

  9. echo "Floor value of $val1 is $zflr1
    ";  

  10. echo "Floor value of $val2 is $zflr2
    ";  

  11. echo "Floor value of $val3 is $zflr3
    ";  

  12. echo "Floor value of $val4 is $zflr4
    ";  

  13. ?>  

Output :

Floor value of 10 is 10
Floor value of -111.13 is -112
Floor value of 100.01 is 100
Floor value of -200 is -200