phxcityslick Posted November 3, 2006 Share Posted November 3, 2006 [code][9] => Array ( [0] => Wins: [1] => 493 ) [10] => Array ( [0] => Losses: [1] => 189 ) [11] => Array ( [0] => Undecided: [1] => 0 ) [12] => Array ( [0] => Credits received: [1] => 30,138.00 )<tr><td>Avg Credits Won per Fight:</td><td><?= $tw_caraway[12][1]/$tw_caraway[9][1] ?></td></tr>[/code]by doing this the answer should be 61.131845 but it's coming out to be 0.0608519269777 this should be a whole number can soone please help me?what is it showing it Link to comment https://forums.phpfreaks.com/topic/26091-array-and-math-problems/ Share on other sites More sharing options...
Orio Posted November 3, 2006 Share Posted November 3, 2006 That's because you have a comma in $tw_caraway[12][1].Try this-[code]<tr><td>Avg Credits Won per Fight:</td><td><?php echo (str_replace(",","",$tw_caraway[12][1])/$tw_caraway[9][1]) ?></td></tr>[/code]EDIT- you should also round a bit the number, to leave only 2 digits after the decimal point-[code]<td><?php echo round((str_replace(",","",$tw_caraway[12][1])/$tw_caraway[9][1]),2) ?></td>[/code]Orio. Link to comment https://forums.phpfreaks.com/topic/26091-array-and-math-problems/#findComment-119272 Share on other sites More sharing options...
phxcityslick Posted November 3, 2006 Author Share Posted November 3, 2006 Thank you i have been on php for less then 2 weeks did not know commas have issuesknow anything about class_http just have one other issue that i need a little guidence on Link to comment https://forums.phpfreaks.com/topic/26091-array-and-math-problems/#findComment-119316 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.