function display_questions() {
$lines = file('questions.txt', FILE_IGNORE_NEW_LINES);
$count = count($lines);
for ($i = 0; $i < $count; $i++) {
$newLines = explode(",", $lines[$i]);
$no_question = $i + 1;
ECHO ('<b>' .$newLines[0]. '</b><br />');
ECHO ('<input type="radio" name="' .$no_question. '" value="' .$newLines[1]. '/>' .$newLines[1]. '<br />');
ECHO ('<input type="radio" name="' .$no_question. '" value="' .$newLines[2]. '/>' .$newLines[2]. '<br />');
ECHO ('<input type="radio" name="' .$no_question. '" value="' .$newLines[3]. '/>' .$newLines[3]. '<br />');
ECHO ('<input type="radio" name="' .$no_question. '" value="' .$newLines[4]. '/>' .$newLines[4]. '<br />');
ECHO ('<br /><br />');
}
}
Here is my questions.txt file look like
- Please select the answer of 5 x 2, 7, 10, 3, 5
- Please select the answer of 5 + 2, 7, 10, 3, 5
- Please select the answer of 5 - 2, 7, 10, 3, 5
- Please select the answer of 25 x 2, 50, 23, 27, 15
- Please select the answer of 12 x 2, 10, 6, 14, 24
I wanted to ECHO the radio inputs and those information are gather from the questions.txt.
However, I am success to ECHO $newLines[0], but I can't ECHO the radio button.
Please advise. Thanks.