Adding a Comma

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
azwebdiva
Forum Newbie
Posts: 1
Joined: Fri Apr 21, 2006 6:43 pm

Adding a Comma

Post by azwebdiva »

I have a number i need to format with a comma. For example:
$120,450.00 is what i would want. The code I have found does
not give me that choice.

What I have found is this:

$total_principal = number_format($loan_amount, 2, '.', ' ');


which gives me:
$149 133.37

How can I add a comma with large money amounts?

Your help is greatly appreciated.

JT[/b]
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

The third argument is the thousands separator. Put a comma there instead of a space.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply