diff --git a/uebung10/api.php b/uebung10/api.php index 2df57c3..31e22c7 100644 --- a/uebung10/api.php +++ b/uebung10/api.php @@ -12,10 +12,14 @@ if (isset($_GET['n'])) { } $questions = $db->getQuestions($n); -$answers[] = array($questions['answer0'], $questions['answer1'], $questions['answer2']); +$fullarray[] = []; +for ($i = 0; $i < len($questions); $i++) { + $answers[] = array($questions['answer0'], $questions['answer1'], $questions['answer2']); + $jsonarray[] = array("id" => $questions['id'], "answers" => $answers, "solution" => $questions['solution']); + $fullarray[] = $jsonarray; +} -$jsonarray[] = array("id" => $questions['id'], "answers" => $answers, "solution" => $questions['solution']); -$questionsobj = json_encode($jsonarray); +$questionsobj = json_encode($fullarray); echo($questionsobj); ?>