Skip to content
PHP Logo

How does the floor() function work in PHP when rounding numbers?

The floor() function in PHP rounds a number down to the nearest integer. This means that it will always return a value that is less than or equal to the input number. To use the floor() function in PHP, simply pass the number you want to round down as an argument.

php
$number = 4.7;
$roundedNumber = floor($number);
echo $roundedNumber; // Output: 4