From 12087cd8aba1ec93082811bfc5974e0ff98bdb54 Mon Sep 17 00:00:00 2001 From: structix Date: Thu, 11 Jul 2019 13:52:49 +0200 Subject: [PATCH] update --- uebung10/api.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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); ?>