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.
Based upon the other answers I'll assume you only update the ratio if it's not zero (Remember you asked for elegance not clarity):
if( !empty($attacker->rep) ) { $attacker->ratio = $defender->rep / $attacker->rep; }
PHP treats 0 as empty.