In PHP, you can round down to the nearest integer through the floor function. The function of the floor function is to round down to the nearest integer. Its syntax is "floor(x)" and the return value is not greater than " The next integer of "x", round off the decimal part of "x".
Recommendation: "PHP Video Tutorial"
In PHP, you can use the floor function to achieve rounding down.
PHP floor() function definition and usage
floor() function rounds down to the nearest integer.
Syntax
floor(x)
Parameters
x Required. A number.
Description
Returns the next integer not greater than x, and rounds the decimal part of x. The type returned by floor() is still float because the range of float values is usually larger than that of integer.
Example
In this example, we will apply the floor() function to different numbers:
<?php echo(floor(0.60)); echo(floor(0.40)); echo(floor(5)); echo(floor(5.1)); echo(floor(-5.1)); echo(floor(-5.9)) ?>
Output:
0 0 5 5 -6 -6
The above is the detailed content of How to round down in php. For more information, please follow other related articles on the PHP Chinese website!