Round down to the nearest integer:
<?phpecho(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));?>The floor() function rounds down to the nearest integer.
Tip: To round up to the nearest integer, check out the ceil() function.
Tip: To round floating point numbers, check out the round() function.
floor( number );
parameter | describe |
---|---|
number | Required. Specifies the value to be rounded down. |
Return value: | The nearest integer value rounded down. |
---|---|
Return type: | Float |
PHP version: | 4+ |