У меня есть 2 текстовых файла, один с вопросами:
1|question 1
2|question 2
...
второй с ответами ^
1|1|answer 1 to q1
2|1|answer 2 to q1
3|2|answer 1 to q2
4|2|answer 2 to q2
...
И сценарий, который выводит вопросы:
function getTable($path_q,$path_a)
{
$qOpen=file($path_q);
$aOpen=file($path_a);
$strResult='<div id="test">';
for($i=0;$i<=sizeof($qOpen);$i++)
{
$masStr[$i]=explode('"',trim($qOpen[$i]));
$masStrClear[$i] = array();
foreach($masStr[$i] as $v)
{
if (!empty($v))
{
$masStrClear[$i][]=trim($v);
}
}
for($j=0;$j<sizeof($masStrClear[$i]);$j++)
{
$question=explode('|',$masStrClear[$i][$j]);
$strResult.='<span id="q'.$question[0].'"><h4>'.$question[1].'?</h4></span>';
}
}
echo $strResult.'</div>';
}
getTable('data/test_1_q.txt','data/test_1_a.txt');
Я хочу добавить:
1) Функция перемешивания для всех вопросов.shuffle($masStr[$i])
не работает.
2) выводит ответы по соответствующим вопросам.Помогите пожалуйста!