hmark Posted January 8, 2010 Share Posted January 8, 2010 Hello again. How can i trim my results to only include two decimal points? I'm using the following: <? while($row = mysql_fetch_array($res) ) { $ind_pred_rate=$row[3]/114155*100; $outd_pred_rate=$row[4]/114155*100; $target_rate=$row[6]/114155*100; print "<tr>\n"; print "<td valign=\"top\">{$row[0]}</td>\n"; print "<td valign=\"top\">{$row[1]}</td>\n"; print "<td valign=\"top\"> {$row[2]} </td>\n"; print "<td valign=\"top\">{$row[3]}</td>\n"; print "<td valign=\"top\">{$ind_pred_rate}</td>\n"; print "<td valign=\"top\">{$row[4]}</td>\n"; print "<td valign=\"top\">{$outd_pred_rate}</td>\n"; print "<td valign=\"top\">{$row[5]}</td>\n"; print "<td valign=\"top\">{$row[6]}</td>\n"; print "<td valign=\"top\">{$target_rate}</td>\n"; print "<td valign=\"top\">{$row[7]}</td>\n"; print "</tr>\n"; } ?> The results of $ind_pred_rate, $outd_pred_rate, and $target_rate are 14 decimal points or more. Any suggestions here? Thank you! Link to comment https://forums.phpfreaks.com/topic/187742-trailing-zeros/ Share on other sites More sharing options...
mrMarcus Posted January 8, 2010 Share Posted January 8, 2010 number_format Link to comment https://forums.phpfreaks.com/topic/187742-trailing-zeros/#findComment-991200 Share on other sites More sharing options...
hmark Posted January 8, 2010 Author Share Posted January 8, 2010 Thank you for the reference. I think I got it!! Thanks again! Link to comment https://forums.phpfreaks.com/topic/187742-trailing-zeros/#findComment-991213 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.