floor(float $value): float
$value is a floating point number that needs to be rounded downwards.
The return value is an integer rounded downward, and is of type a floating point number.
<?php
// Round down example
$num1 = 5.9;
$num2 = -3.2;
echo floor($num1); // Output 5
echo "\n";
echo floor($num2); // Output -4
?>
Calculation pagination <br> When you need to calculate the total number of pages based on the total number and the number of pages per page, you can use floor() to round down first and then add one to ensure that the page is correct.
Price calculation <br> Sometimes the price is rounded downward to prevent situations that exceed the budget.
Coordinate processing <br> When processing map coordinates or graphics, floor() is commonly used to round down the floating point coordinates to pixel points.
floor() is different from ceil() (rounded up) and round() (rounded) and choose a suitable function to avoid calculation errors.
When there is a negative number, floor() will round in the direction of a smaller integer, such as -3.2 will be taken to -4 .
<?php
// More About floor() Please refer to the usage of the function:
// https://gitbox.net/manual/en/function.floor.php
?>