Jump to content

commas in numbers


Braet

Recommended Posts

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,578

So 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
Link to comment
https://forums.phpfreaks.com/topic/18079-commas-in-numbers/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.