php - Creating a level of numbers for a pass scoring system -


i have set of values json_decode , number being row 'pass_levels' , letter being row 'pass_level_name'.

90 -> a, 80 -> b, 70 -> c 

i have score if above or below number want show letter. if score 85 shows b. problem have code below if score above of numbers shows c regardless.

i know if > 90 echo variables not set , amount of variables change. change , variables might be:

a -> 95, b -> 90, c -> 80, d -> 70, e -> 60, f -> 50. 

in circumstances scored below lowest number fail.

$score = $row['score'];   $levels = json_decode($row['pass_levels']); $levels_name = json_decode($row['pass_level_name']);  foreach(array_combine($levels, $levels_name) $level => $level_name){                  }  if($score >= $level){ echo $score.'% '.$level_name; } else { echo "fail"; } 

i hope i've explained enough me.

thanks


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -