Jump to content

Remove decimal places


EchoFool

Recommended Posts

I have this:

 

$Gain = number_format($Gain,0);

 

 

To remove the decimal places.. but it adds the "," symbol so:

 

1000 becomes 1,000. Which then causes my UPDATE query to crash because of the symbol. Is there a way to remove the comma but still removing the decimal places at the same time?

Link to comment
https://forums.phpfreaks.com/topic/86828-remove-decimal-places/
Share on other sites

There are a few potential solutions. 

1. Check php.net under the number_format function. Check in the user's notes to see if anyone has a better function for what you want.

2. Look up tutorials online about formatting numbers.

3. Look up tutorals ON that function and see if there is a way to use it to get what you need.

4. Use regular Expressions or substr to find and and remove the ',' symbol inside the string/number.

Link to comment
https://forums.phpfreaks.com/topic/86828-remove-decimal-places/#findComment-443752
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.