What are the potential issues with randomly selecting and evaluating questions in a PHP quiz without using a database?

One potential issue with randomly selecting and evaluating questions in a PHP quiz without using a database is that the questions may not be unique each time the quiz is taken, leading to a lack of variety for users. To solve this issue, you can store the questions in an array and shuffle the array before selecting questions to ensure a different set of questions each time.

// Define an array of quiz questions
$questions = [
    "What is the capital of France?",
    "Who wrote 'Romeo and Juliet'?",
    "What is the largest mammal on Earth?",
    // Add more questions here
];

// Shuffle the array of questions
shuffle($questions);

// Select a random subset of questions for the quiz
$selected_questions = array_slice($questions, 0, 5);

// Display the selected questions
foreach ($selected_questions as $key => $question) {
    echo "Question " . ($key + 1) . ": " . $question . "<br>";
}