Jump to content

remove comma before adding


flemingmike

Recommended Posts

hello all,

 

i have a small problem.  i have a bunch of prices in a database like 243.49 and 1,256.22 etc.

 

the problem is that when i try to add multiple prices that one of the fields is over 1000, it is treating it as 1 (i believe because of the comma.)

 

is there a way to remove the comma, but not the decimal if it exists and then add it back to the $total if it is over 1000?

 

  $pamount=$row2['amount'];
  
$total += $pamount;

Link to comment
https://forums.phpfreaks.com/topic/221131-remove-comma-before-adding/
Share on other sites

Remove - http://us3.php.net/manual/en/function.str-replace.php

Put back - http://us2.php.net/manual/en/function.number-format.php

 

All the basic things that php (or mysql) can do, can be found by looking in the php/mysql documentation.

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.