w3resource

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:

<?php
$val1=10;
$val2=-111.13;
$val3=100.01;
$val4=-200;
$zflr1=floor($val1);
$zflr2=floor($val2);
$zflr3=floor($val3);
$zflr4=floor($val4);
echo "Floor value of $val1 is $zflr1<br />";
echo "Floor value of $val2 is $zflr2<br />";
echo "Floor value of $val3 is $zflr3<br />";
echo "Floor value of $val4 is $zflr4<br />";
?>

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

View the example in the browser

See also

PHP Function Reference

Previous: expm1
Next: getrandmax



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/php/function-reference/floor.php