My application generates a random integer between 0 and 1000.
I have 5 ranges: 0-50, 51-250, 251-500, 501-700, 701-1000. (Note that the range sizes are not equal.)
I will call these ranges: “0”,”50″,”250″,”500″,”700″, respectively (will store those names in my database).
I know that i could do the following:
if ($number > 700 && $number <=1000)
$num_range='700';
else if...
… and so on.
But is there a more efficient way of doing it?
Thanks a lot in advance. Regards
Utilize
elseifefficiently: