MrXander Posted September 22, 2012 Share Posted September 22, 2012 Hi Guys, This might be a really dim question, but I need assistance with the round() function. I am trying to show a rounded figure of, for example $3.50, but using round, it is dropping the last zero. The line of code being used is: $price1 = round($personal1 * $rate, 2); Is there anyway to avoid this and display the last zero? Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/268658-help-with-round/ Share on other sites More sharing options...
kicken Posted September 22, 2012 Share Posted September 22, 2012 Use number_format instead of round. Quote Link to comment https://forums.phpfreaks.com/topic/268658-help-with-round/#findComment-1379988 Share on other sites More sharing options...
ManiacDan Posted September 22, 2012 Share Posted September 22, 2012 Note that number_format is only to be used immediately before printing. Don't do additional math on a number which has been formatted. Quote Link to comment https://forums.phpfreaks.com/topic/268658-help-with-round/#findComment-1379996 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.