yii2 and mysql grading system.

i need to create a system that calculate grades based on marks, the yii2 code must be like the php code below but grading must come from the database, for instance when i select 73 on backend,the frontend must show an ‘A’ on that subject:


$array[‘A’] = range(70, 100); $array[‘B’] = range(60, 69); $array[‘C’] = range(50, 59); /* etc */ $db_score = 92; // <-- from db foreach($array as $k => $v){ if(in_array($db_score, $v)){ $score = $k; }