To find the floor of a number using php, the easiest way is to use the php **floor()** function.

`echo floor(2.434); // Output: 2`

Finding the floor of a number in php is easy. We can round down numbers to the nearest integer with the php **floor()** function.

`echo floor(5.4); // Output: 5`

We can use the **floor()** function to find the floor of both positive and negative numbers.

```
echo floor(7.2); // Output: 7
echo floor(-1.1); // Output: -2
```

If you pass an integer to the **floor()** function, you will get that integer back.

`echo floor(9); // Output: 9`

If you want to round up instead of rounding down, you can use the php **ceil()** function.

## Finding the Floor of Positive Number with floor in php

Using the **floor()** function, we can find the floor of positive numbers in php.

A few examples of calling the **floor()** function with positive numbers are below:

```
echo floor(1); // Output: 1
echo floor(381.38); // Output: 381
echo floor(100.123786); // Output: 100
echo floor(9.9999); // Output: 9
echo floor(9.0001); // Output: 9
```

## Finding the Floor of Negative Number with floor in php

Using the **floor()** function, we can find the floor of negative numbers in php.

A few examples of calling the **floor()** function with negative numbers are below:

```
echo floor(-1); // Output: -1
echo floor(-381.38); // Output: -382
echo floor(-100.123786); // Output:-101
echo floor(-9.9999); // Output: -10
echo floor(-9.0001); // Output: -10
```

Hopefully this article has been helpful for you to use the php **floor()** function to find the floor of a number.

## Leave a Reply