Round numbers to two decimals in PHP

Description

The following code shows how to round numbers to two decimals.

Example


//w w w.j av a  2 s .c om
<?php
    echo(round(4.96754,2) . "<br>");
    echo(round(7.045,2) . "<br>");
    echo(round(7.055,2));
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Development »




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