blurredvision Posted August 5, 2008 Share Posted August 5, 2008 I have a listing of percentages, and the calculation is a simple divide this number by that number. However, I want to return the decimal plus 3 digits afterwards, for example, I'd want it to show (without the quote of course) ".800". Instead, it shows ".8". Is there a simple way to have it show 0's on the end of these decimal numbers? Link to comment https://forums.phpfreaks.com/topic/118187-solved-how-can-i-force-800-to-show-instead-of-just-8/ Share on other sites More sharing options...
ShaunO Posted August 5, 2008 Share Posted August 5, 2008 Take a look at the number_format() function This will do what you need Link to comment https://forums.phpfreaks.com/topic/118187-solved-how-can-i-force-800-to-show-instead-of-just-8/#findComment-608192 Share on other sites More sharing options...
Andy-H Posted August 5, 2008 Share Posted August 5, 2008 round($var, 3); number_format($var, 3); Will display the 0 too tho. Link to comment https://forums.phpfreaks.com/topic/118187-solved-how-can-i-force-800-to-show-instead-of-just-8/#findComment-608193 Share on other sites More sharing options...
Andy-H Posted August 5, 2008 Share Posted August 5, 2008 Round should be better (obviously as it rounds it up to the nearest thousandth in this case). Link to comment https://forums.phpfreaks.com/topic/118187-solved-how-can-i-force-800-to-show-instead-of-just-8/#findComment-608194 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.