EchoFool Posted January 19, 2008 Share Posted January 19, 2008 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? Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted January 19, 2008 Share Posted January 19, 2008 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. Quote Link to comment Share on other sites More sharing options...
Barand Posted January 19, 2008 Share Posted January 19, 2008 many ways <?php $n = 123.456; echo round ($n); // 123 echo '<br>'; echo intval ($n); // 123 echo '<br>'; echo floor ($n); // 123 echo '<br>'; echo (int)$n; // 123 echo '<br>'; ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.