I got this code, and I am trying to get the Win/divided by total games played number, which should be under 1. Like 0.75.
foreach($dat as $stats) {
if($stats['championId'] != 0) {
echo '<br><br>Champion ID : '.$stats['championId'];
echo '<br>Total Games Played : '. $stats['totalGamesPlayed'];
foreach($stats['stats'] as $stat) {
if($stat['statType'] == 'TOTAL_SESSIONS_WON')
echo '<br> Won: '.$stat['value'];
$ratio = $stat['value'] / $stats['totalGamesPlayed'];
echo '<br>' .$ratio;
}
}
}
And that piece of code is right, expect the part of the $ratio.
Cause when I echo it, I get like 30 numbers, and only 1 is the right one.
Can you guide me through that?
You probably need curly brackets
{ ... }around the secondifstatements. If you don’t use curly brackets, only the first statement after theifcondition will be evaluated as part of theifconstruct.