<?php
$line = 'What is a dog?, A pet, A human, A house, A train';
//This cose assumes no commas in the question or answers.
$answers = explode(',', $line);
//pull the question into a variable
$question = $answers[0];
//remove the question from the list of answers
array_shift ($answers);
//add the array to your result array
$quizItems[]=array('question'=>$question, 'answers'=>$answers );
$line = 'What is a car?, A vehicle, A tool, A number, A person';
//This cose assumes no commas in the question or answers.
$answers = explode(',', $line);
//pull the question into a variable
$question = $answers[0];
//remove the question from the list of answers
array_shift ($answers);
//add the array to your result array
$quizItems[]=array('question'=>$question, 'answers'=>$answers );
foreach ($quizItems as $quizItem){
echo '<b>'.$quizItem['question']."</b>\n".
implode("\n", $quizItem['answers'])."\n\n\n";
}
?>