karldesign Posted August 20, 2007 Share Posted August 20, 2007 I have the following output from a calculation: 211.5 I want to print this to screen as 211.50 (currency), but the round($value,2) doesn't force a rounding... is it possible? Quote Link to comment https://forums.phpfreaks.com/topic/65789-currency-rounding/ Share on other sites More sharing options...
AndyB Posted August 20, 2007 Share Posted August 20, 2007 http://ca.php.net/manual/en/function.money-format.php Quote Link to comment https://forums.phpfreaks.com/topic/65789-currency-rounding/#findComment-328690 Share on other sites More sharing options...
tibberous Posted August 20, 2007 Share Posted August 20, 2007 $money = explode(".", $money); $money[1] = substr($money[1], 0, 2); $money = $money[0] . "." . (strlen($money[1]) < 1 ? "0" : "") . (strlen($money[1]) < 2 ? "0" : ""); Quote Link to comment https://forums.phpfreaks.com/topic/65789-currency-rounding/#findComment-328694 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.