PS If you really want to do it in PHP then you can apply the same method to an array
$thresholds = array(
'-' => [0, 100],
'contributor' => [101, 1000],
'author' => [1001, 10000],
'editor' => [10001, 100000],
'administrator' => [100001, 999999999]
);
echo getUserRole(50000, $thresholds); //--> editor
function getUserRole($current_balance, $thresholds)
{
foreach ( $thresholds as $role => $range ) {
if ( $range[0] <= $current_balance && $current_balance <= $range[1] ) {
return $role;
}
}
return false;
}