Solved: print of double/float

All your question about php
Post Reply
mister_v
Posts: 188
Joined: Thu Mar 04, 2010 9:19 pm

Solved: print of double/float

Post 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
Last edited by mister_v on Wed Feb 09, 2011 8:05 pm, edited 1 time in total.
chris
Site Admin
Posts: 194
Joined: Mon Jul 21, 2008 9:52 am

Re: print of double/float

Post 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
Post Reply