[pmwiki-devel] Simple PHP question

Sandy sandy at onebit.ca
Mon Mar 12 17:08:57 CDT 2007


I want to convert floating point to strings and output them into the 
HTML file. Round to two after the decimal point.

 From php.net, it looks like this is the right way:

$a=2.123456789;
echo sprintf('%f5.2',$a);

I get
2.1234575

So,

1. How do I get 2.12
2. Where does that final 5 come from? I'm guessing the 6 gets rounded up 
to 7, but the 5?

Help?

TIA,

Sandy




More information about the pmwiki-devel mailing list