Round numbers down to the nearest integer:
<?php
echo(floor(0.60) . "<br>");
echo(floor(0.40) . "<br>");
echo(floor(5) . "<br>");
echo(floor(5.1) . "<br>");
echo(floor(-5.1) . "<br>");
echo(floor(-5.9));
?>
Try it Yourself »
The floor() function rounds a number DOWN to the nearest integer, if necessary, and returns the result.
Tip: To round a number UP to the nearest integer, look at the ceil() function.
Tip: To round a floating-point number, look at the round() function.
floor(
number);
Parameter | Description |
---|---|
number | Required. Specifies the number to round down |
Return Value: | The value rounded down to the nearest integer |
---|---|
Return Type: | Float |
PHP Version: | 4+ |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!