Example 1 — Round numbers down
See how floor() cuts off the decimal part of positive numbers.
<?php
echo floor(4.7) . PHP_EOL;
echo floor(4.2) . PHP_EOL;
echo floor(9) . PHP_EOL; How It Works
- floor(4.7) goes down to 4, not up to 5.
- floor(4.2) also goes down to 4.
- floor(9) stays 9 because there is nothing to round.
- The values are floats, but PHP prints them without .0.

