Basically, I have a number:
<?
$rating = 72.7777777778;
?>
I basically want to do some maths to create this number as 80.
If the number was 62.7777777778, the number would be 60.
I want the numbers rounded like so:
20, 40, 60, 80, 100
So say I have three numbers:
36.999, 47, 91
I would get:
40, 40, 100
How do I go about doing this? I’ve tried with round, ceil & floor but I haven’t got anywhere.
Would it just be easier doing something like so?
if ($rating < 30){
$rating = 20;
}elseif (($rating > 30) && ($rating < 50)){
$rating = 40;
}elseif (($rating > 50) && ($rating < 70)){
$rating = 60;
}elseif (($rating > 70) && ($rating < 90)){
$rating = 80;
}else{
$rating = 100;
}
etc…
1 Answer