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? Quote 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 Quote 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. Quote 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). Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.