Hi. I'm creating a short-answer quiz. The questions has one text area each for answer. However, for each question there are several answer suggestions in the database. I'd like to compare the value post by the text area with the suggestions.
$answers = explode(" ", $ans[$arr_ind]); //$ans[$arr_ind] holds answers from form
foreach ($answers as $answer) {
$answer = trim($answer);
if(stripos($atext[$arr_ind], $answer)!== false){ //$atext[$arr_ind] holds answer suggestions
//correct
$result = "<p align='justify'><img src='image/mark.png' border='0' width='20' height='20'></img><b> YOUR ANSWER: </b>". $ans[$arr_ind]. "</p>";
//$correct = 1;
}
else
$result = "<p align='justify'><img src='image/cross.png' border='0' width='20' height='20'></img> <b>YOUR ANSWER: </b>". $ans[$arr_ind]. "</p>";
}//foreach
echo $result;
///////////////// COMPARE USER INPUT W/ ANSWERS /////////////////
Right now the code only compares with the first suggestion it finds. Any help would be very much appreciated. Thanks.
Atikah