Floor function in PHP
The floor() is an inbuilt function of PHP, which is used to round numbers down to the nearest integer if necessary, and returns the result. This function always returns a float number as range of the next lowest integer value (float). It is available in PHP 4 and above.
Syntax of PHP floor()floor ( float $num ) : float
Here, $num is the number to be rounded down.
Example of Floor function
These are the some examples of floor() function -
<?php
$a=12;
$b=-121.02;
$c=103.03;
$d=-230;
$x1=floor($a);
$x2=floor($b);
$x3=floor($c);
$x4=floor($d);
echo "Floor value of $a is $x1<br />";
echo "Floor value of $b is $x2<br />";
echo "Floor value of $c is $x3<br />";
echo "Floor value of $d is $x4<br />";
?>
Output of the above code -
Floor value of 12 is 12
Floor value of -121.02 is -122
Floor value of 103.03 is 103
Floor value of -230 is -230
Related Articles
PHP qr code generatorFibonacci series program
PHP array length
PHP String Contains
PHP remove last character from string
PHP random quote generator
PHP calculate percentage of total
PHP MySQL sanitize
Display PDF using an AJAX call
How to fetch data from database in php and display in pdf
How to read CSV file in PHP and store in MySQL
How to create a doc file using PHP
PHP SplFileObject Examples
How to Upload a File in PHP
Sending HTML form data to an email address