Cruisecar Posted April 26, 2006 Share Posted April 26, 2006 Hey,Firstly thank you for reading this, my problem is a very simple one, yet it seems to be very hard for me to achieve the needed result. Basicly, I have a string ($money) pulled from a database, it could be any value from 0 or more. I need to add commas into that string every 3 numbers - it must be added from the end to the begining. $money = "1000000"After going through the function it should be "1,000,000". I tried using explode, and attempted using a wildcard - but there is none, also it would make the number "100,000,0".I hope someone can help me! And once again, thankyou for reading. Link to comment https://forums.phpfreaks.com/topic/8477-exploding-a-string-adding-commas/ Share on other sites More sharing options...
litebearer Posted April 26, 2006 Share Posted April 26, 2006 Try[code]$formatted = number_format($money,2);[/code]Lite... Link to comment https://forums.phpfreaks.com/topic/8477-exploding-a-string-adding-commas/#findComment-31005 Share on other sites More sharing options...
Cruisecar Posted April 26, 2006 Author Share Posted April 26, 2006 Thanks for your fast reply, worked a charm! I will definutely visit here more often. Link to comment https://forums.phpfreaks.com/topic/8477-exploding-a-string-adding-commas/#findComment-31006 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.