Putting commas in correct places on a number

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
djwk
Forum Commoner
Posts: 56
Joined: Tue Mar 07, 2006 2:14 pm

Putting commas in correct places on a number

Post by djwk »

Hey I'm looking for something simple to display a number with commas seperating millions, billions, hundred thousands etc.

So lets say I had:

Code: Select all

1248290
I want it to display

Code: Select all

1,248,290
or

Code: Select all

24920391394
to

Code: Select all

24,920,391,394

I don't want to have to change how long the number is, like when its a billion i dont want to have to specify that its at a billion. I hope this explains what I want the script to do.

Can anyone help out?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

djwk
Forum Commoner
Posts: 56
Joined: Tue Mar 07, 2006 2:14 pm

Post by djwk »

Thanks, works a charm :)
Post Reply