commas in money

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
User avatar
dstefani
Forum Contributor
Posts: 140
Joined: Sat Jan 11, 2003 9:34 am
Location: Meridian Idaho, USA

commas in money

Post by dstefani »

How do I get a comma in a US dollar amount like $1925.95 to $1,925.95

Is the a way to format it, or do I have to do a regexp or something?

Thanks,

- dstefani
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

User avatar
dstefani
Forum Contributor
Posts: 140
Joined: Sat Jan 11, 2003 9:34 am
Location: Meridian Idaho, USA

Post by dstefani »

OK, that's cool, but how about this:

I've got a number of 1200 I'm using sprint to add the two zeros after the decimal. It works.

How do I get the comma and the effect of sprintf ? ($1,200.00)

Maybe I'm missing something.

Thanks,

- dstefani
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post by nickvd »

dstefani wrote:OK, that's cool, but how about this:

I've got a number of 1200 I'm using sprint to add the two zeros after the decimal. It works.

How do I get the comma and the effect of sprintf ? ($1,200.00)

Maybe I'm missing something.

Thanks,

- dstefani
I really don't mean to be rude.. but did you even read the manual page for money_format() that feyd posted???

It certainly doesn't seem like it.
User avatar
dstefani
Forum Contributor
Posts: 140
Joined: Sat Jan 11, 2003 9:34 am
Location: Meridian Idaho, USA

Post by dstefani »

It's OK, be rude, I scanned it, I'm doind 3 things at one.

When I posted the last one I felt a shiver of guilt as I posted (didn't do enough of my own research)

- Sorry

- dstefani :twisted: Evil laziness
Post Reply