Much like this site, my current project has reputation and in the script that I\'m working on I need to calculate the ratio between two users\' reputations.
Use a ternary operator to check if the divider is zero or not.
$attacker->ratio = $attacker->rep > 0 ? $defender->rep / $attacker->rep : 1; $defender->ratio = $defender->rep > 0 ? $attacker->rep / $defender->rep : 1;
Use whatever you wish instead of the value 1 as default.
1