Round numbers down to the nearest integer in PHP

Description

The following code shows how to round numbers down to the nearest integer.

Example


/*from  w w w  . j  av a 2s  .  c o m*/
<?php
    echo(floor(0.65) . "<br>");
    echo(floor(0.45) . "<br>");
    echo(floor(5) . "<br>");
    echo(floor(5.1) . "<br>");
    echo(floor(-5.1) . "<br>");
    echo(floor(-5.9));
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Development »




Environment
Error
Hash
Include
Locale
Math
Network
Output
Reflection
PHP Regular Expressions