PHP: Comma as decimal separator

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
thiscatis
Forum Contributor
Posts: 434
Joined: Thu Jul 20, 2006 11:00 am

PHP: Comma as decimal separator

Post 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
Last edited by thiscatis on Wed Jun 20, 2007 8:15 am, edited 1 time in total.
User avatar
arturm
Forum Commoner
Posts: 86
Joined: Fri Apr 13, 2007 8:29 am
Location: NY
Contact:

Post by arturm »

You can user number_format() function

Code: Select all

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