Round numbers in PHP

Description

The following code shows how to round numbers.

Example


/*  w ww .  j  a v a  2 s  . c  o m*/
<?php
    echo(round(0.60) . "<br>");
    echo(round(0.50) . "<br>");
    echo(round(0.49) . "<br>");
    echo(round(-4.40) . "<br>");
    echo(round(-4.60));
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Development »




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