billhobbs Posted September 26, 2010 Share Posted September 26, 2010 <?php $totalcreditstd = $row_rsCreditPurchaseMoney['SUM(quantity)']; $totalcreditsdollar = $totalcreditstd * $Mutliplier; echo $totalcreditsdollar; ?> I'm using the above calculation to display a total amount. Problem is that if the calculation total is 7.5 I want it to show up as 7.50 I want to force the second number. How can I do that? Thanks. Quote Link to comment Share on other sites More sharing options...
Alex Posted September 26, 2010 Share Posted September 26, 2010 echo number_format(7.5, 2); // 7.50 number_format Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted September 26, 2010 Share Posted September 26, 2010 Or possibly: money_format() Quote Link to comment Share on other sites More sharing options...
billhobbs Posted September 26, 2010 Author Share Posted September 26, 2010 Perfect, thanks. Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted September 26, 2010 Share Posted September 26, 2010 or... echo round($number, 2); Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted September 26, 2010 Share Posted September 26, 2010 If you're doing money / financial calculations make sure you're using BC or GMP math functions. Do not use floats. Quote Link to comment Share on other sites More sharing options...
Alex Posted September 26, 2010 Share Posted September 26, 2010 or... echo round($number, 2); round(7.5, 2); will output 7.5 Quote Link to comment 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.