Page 1 of 1

PHP: Comma as decimal separator

Posted: Wed Jun 20, 2007 8:10 am
by thiscatis
I'm getting the results from a query in a list on a PHP page.
The results are all numbers, with digits after the . (11.14% | 12.17% etc..)
I want to have them like this: 11,14% | 12,17% etc..
So how can I get the comma as decimal separator

Posted: Wed Jun 20, 2007 8:15 am
by arturm
You can user number_format() function

Code: Select all

$number = '11.14';
echo number_format($number, 2, ',', ' ')."%";