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