$arr = $results->row();
$score = 0;
foreach ($arr as &$i) {
switch($i){
case ($i <= 4 AND $i >= 1):
$score += 1;
break;
case ($i < 8 AND $i > 4):
$score += 3;
break;
case ($i >= 8):
$score += .5;
break;
}
}
echo $score
This is my current code that adds up a total value based on about 30 db (SQL) entries. Kind of like a grading ruberik. I need help improving the above code. Is there a better way to do this?
Also. Some of these (ie, rows 3,5,8 need to be scored differently.) How do I omit these rows in this logic and pass them to be scored differently?
This is a codeigniter function, so I'd love it if somebody could show me a quick easy, pretty way to do this! Thanks a lot!