Well, one method is:
function roundUp($num, $nearest) {
$mod = $num % $nearest;
if ($mod == 0)
return $num;
else
return $num - $mod + $nearest;
}
Then use as
$num = roundUp($num, 5);
Then again, it might be more prudent to do a
$num = round($num);
before finding $mod in case $num is floating point.
The modulo operator should implicitly typecast to integer.
If you arent certain that $num (or $nearest) will always be numeric, you might even add a check with is_numeric() before doing any processing.