Untitled
unknown
plain_text
a year ago
802 B
10
Indexable
<?php
$correct_answers = array (
"q1" => "known",
"q2" => "contentment"
);
$user_answers = array(
"q1" => ($_POST['q1']),
"q2" => ($_POST['q2'])
);
$score = 0;
$questions = array(
"q1" => "What is love based on the given choices?",
"q2" => "What is happiness based on the given choices?"
);
foreach ($questions as $key => $question) {
echo "Question: $question<br>";
echo "Your Answer: " . $user_answers[$key] . "<br>";
if ($user_answers[$key] === $correct_answers[$key]) {
echo "Correct!<br><br>";
$score++;
} else {
echo "Incorrect! The correct answer is " . $correct_answers[$key] . ".<br><br>";
}
}
echo "<strong>Your Total Score: $score out of 2</strong><br>";
?>Editor is loading...
Leave a Comment