Braet Posted August 20, 2006 Share Posted August 20, 2006 I have a preg_match_all going through some information I submit by form, and pulling out numbers. These numbers are often in the millions therefore have commas in them. When I would add them, it would add each section, ie:123,456,789 +123,456,789 would = 2736 instead of the actual 246,913,578So I stripped the commas:[code]$numb2 = str_replace(",", "", $numb);[/code]Now it adds properly (yaay), but is very hard to read w/out those commas which brings me to my question, any tutorial that you can point me to (as my searches have yeilded nothing and "the" php manual is still confusing to this php newb) that will explain how to treat numbers with commas or a simple fix to either keep those commas and have it add from the array properly or to put the commas back in once the addition is done?tia yet again-Brae Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted August 20, 2006 Share Posted August 20, 2006 The number_format() function is your friend here, you can use it show 1000 separators, specify the number of decimal places and the synbol used to show a decimal placehttp://uk.php.net/number_format Quote Link to comment Share on other sites More sharing options...
Braet Posted August 20, 2006 Author Share Posted August 20, 2006 bingo! ty - driving me mad and have been googling for days - that is (once I figured out how to properly use it) exactly what I needed there. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.