tags:

views:

67

answers:

1

I am looking at the money_format function in php and confused on how to get it to format the way I want. I do not want USD in front of my string, I want a comma every 3 digits and 2 decimal points so 12345.67 will be formated to $12,345.67

Thanks.

+5  A: 

Have you looked at number_format? It's a little easier I think.

print number_format( 1234567, 2, ",", "." ); for example.

CharlesLeaf
Agreed, I honestly don't know why they even created `money_format()`, it's like a foreign language.
animuson
It's a wrapper for C's `strfmon` function. It's just one of those little things that give PHP a easy learning curve for developers who are used to other languages (and their default functionality). It actually can be quite useful for formatting currency for plain-text situations where you want to align (like str_pad could do)
CharlesLeaf
Thanks, I had to switch the placement of the `,` and `.` params to make it US instead of EURO style.
John Isaacks