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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.