How can multiple user inputs be efficiently compared to predefined solutions in a PHP-based quiz or puzzle?

When comparing multiple user inputs to predefined solutions in a PHP-based quiz or puzzle, one efficient way to do so is by storing the predefined solutions in an array and then iterating through the user inputs to check if they match any of the solutions. This can be achieved using a loop and conditional statements to compare each user input with the predefined solutions.

// Predefined solutions
$predefinedSolutions = array("solution1", "solution2", "solution3");

// User inputs
$userInputs = array("input1", "input2", "input3");

// Check user inputs against predefined solutions
foreach ($userInputs as $input) {
    if (in_array($input, $predefinedSolutions)) {
        echo "Correct!";
    } else {
        echo "Incorrect!";
    }
}