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? Link to comment https://forums.phpfreaks.com/topic/86828-remove-decimal-places/ 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. Link to comment https://forums.phpfreaks.com/topic/86828-remove-decimal-places/#findComment-443752 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>'; ?> Link to comment https://forums.phpfreaks.com/topic/86828-remove-decimal-places/#findComment-443825 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.