Page 1 of 1

Solved: print of double/float

Posted: Mon Jun 14, 2010 8:28 pm
by mister_v
Hello,

I want to print a double/float value,
but i get to much numbers behind the comma.

example: 55.3333333333

I only want 2 numbers behind the comma.

Thanks

Re: print of double/float

Posted: Mon Jun 14, 2010 11:14 pm
by chris
You can do this with the function number_format()

Code: Select all

$float = 55.3333333333;
$new_num = number_format($float, 2);

echo $new_num; //55.33