timmah1 Posted July 9, 2008 Share Posted July 9, 2008 I'm trying to get 10% of a number. I am doing this $number = $row1['total'] * .10; But, the number is showing a decimal If I have the number 328,194.00 10% is this 32,819.40 it is showing me 32819.4 but I only need it to show 3281940 How do I do I get the decimal out of the percentage? Thanks in advance Link to comment https://forums.phpfreaks.com/topic/113944-solved-getting-a-percentage/ Share on other sites More sharing options...
kenrbnsn Posted July 9, 2008 Share Posted July 9, 2008 Look at the function number_format() Ken Link to comment https://forums.phpfreaks.com/topic/113944-solved-getting-a-percentage/#findComment-585560 Share on other sites More sharing options...
lemmin Posted July 9, 2008 Share Posted July 9, 2008 10% of 328,194.00 would be 32,819.4, not 3,281,940.00 so I am confused about what you want. You can use the function round() to round the number or floor() to truncate at the decimal. Or even number_format() to change the number of decimals returned: http://www.php.net/manual/en/function.round.php http://www.php.net/manual/en/function.floor.php http://www.php.net/manual/en/function.number-format.php Link to comment https://forums.phpfreaks.com/topic/113944-solved-getting-a-percentage/#findComment-585563 Share on other sites More sharing options...
timmah1 Posted July 9, 2008 Author Share Posted July 9, 2008 i was trying to show two points past the decimal so instead of seeing 32,819.4, i would see 32,819.40 but i'm just going to eliminate that and round it thanks for your help Link to comment https://forums.phpfreaks.com/topic/113944-solved-getting-a-percentage/#findComment-585573 Share on other sites More sharing options...
corbin Posted July 9, 2008 Share Posted July 9, 2008 Look at the function number_format() Ken That can keep two decimals after the number, if you're still interested in retaining the decimals. Link to comment https://forums.phpfreaks.com/topic/113944-solved-getting-a-percentage/#findComment-585588 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.