Quiz setting users grade I have made this code to determine the users grade for a quiz. However I've just been thinking that maybe I could shorten the code somehow? as its just a lot of if and elif statements.

if($_SESSION['numberQuestions'] == 10){
        if($_SESSION['score'] == 10){
            $grade = "A+";
        }
        elseif($_SESSION['score'] == 9){
            $grade = "A";
        }
        elseif($_SESSION['score'] == 8){
            $grade = "B";
        }
        elseif($_SESSION['score'] == 7){
            $grade = "C";
        }
        elseif($_SESSION['score'] == 6){
            $grade = "D";
        }
        elseif($_SESSION['score'] &lt;= 5){
            $grade = "F";
        }
    }
    if($_SESSION['numberQuestions'] == 5){
        if($_SESSION['score'] == 5){
            $grade = "A+";
        }
        elseif($_SESSION['score'] == 4){
            $grade = "A";
        }
        elseif($_SESSION['score'] == 3){
            $grade = "B";
        }
        elseif($_SESSION['score'] == 2){
            $grade = "C";
        }
        elseif($_SESSION['score'] == 1){
            $grade = "D";
        }
        elseif($_SESSION['score'] == 0){
            $grade = "F";
        }
    }
You could use an array of grades:

$grades = Array("F","F","F","F","F","F","D","C","B","A","A+");
if($_SESSION['numberQuestions'] == 10){
    if ($_SESSION['score'] &lt;= 10 and $_SESSION['score'] &gt;= 0) {
        $grade = $grades[$_SESSION['score']];
    } else {
        $grade = 'Unknown';
    }
}


Use the same method for the second test.