Round numbers up to the nearest integer in PHP

Description

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

Example


/*from   w  ww. j  av  a 2s.  c  o m*/
<?php
    echo(ceil(0.65) . "<br>");
    echo(ceil(0.45) . "<br>");
    echo(ceil(5) . "<br>");
    echo(ceil(5.5) . "<br>");
    echo(ceil(-5.5) . "<br>");
    echo(ceil(-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