phpbeginner Posted September 3, 2006 Share Posted September 3, 2006 Hello, I have a quick question. I am doing a stats program for a hockey team and the question I have is that I have the decimals correct for the goaltenders goals against average and save % as I wish, except for the fact that if its an even # like 2 it will display 2 rather than 2.00. Works fine when the #'s are not even rounding off to 2 and 3 decimals respectively. Here is the code for the GAA....$p_array[$playerid][gaa] = ROUND('1.00' * ($p_array[$playerid][goalsa]) * (60/$p_array[$playerid][minutes]), 2);Any help would be appreciated......thanks in advance ! Link to comment https://forums.phpfreaks.com/topic/19576-decimal-help/ Share on other sites More sharing options...
AndyB Posted September 3, 2006 Share Posted September 3, 2006 http://ca.php.net/manual/en/function.number-format.php Link to comment https://forums.phpfreaks.com/topic/19576-decimal-help/#findComment-85171 Share on other sites More sharing options...
phpbeginner Posted September 3, 2006 Author Share Posted September 3, 2006 thanks, thought there may have been something I could do here in this snippet....$p_array[$playerid][gaa] = ROUND('1.00' * ($p_array[$playerid][goalsa]) * (60/$p_array[$playerid][minutes]), 2); like this....$p_array[$playerid][gaa] = ROUND('1.00' * ($p_array[$playerid][goalsa]) * (60/$p_array[$playerid][minutes]), 2,'.',' '); Link to comment https://forums.phpfreaks.com/topic/19576-decimal-help/#findComment-85181 Share on other sites More sharing options...
wildteen88 Posted September 3, 2006 Share Posted September 3, 2006 wrap number_format around your round function:[code=php:0]$pcent = round('1.00' * ($p_array[$playerid]['goalsa']) * (60/$p_array[$playerid]['minutes']), 2);$p_array[$playerid]['gaa'] = number_format($pcent, 2, '.', ',');[/code] Link to comment https://forums.phpfreaks.com/topic/19576-decimal-help/#findComment-85197 Share on other sites More sharing options...
phpbeginner Posted September 3, 2006 Author Share Posted September 3, 2006 Thanks so much.....works beautiful. Link to comment https://forums.phpfreaks.com/topic/19576-decimal-help/#findComment-85207 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.