Nayish Nayish - 9 months ago 90
PHP Question

Printing PHP float with 3 digits after the decimal point?

Is there an easy way to

echo
a float number with a specific amount of digits after the decimal point?

For example:
$sum = 3.1234566768;
I would like to echo $sum and get:
3.12
.

Answer Source

use number_format()

number_format($sum,2);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download