From 1d7767dc672cc3bfe3b979ef25292c27cca16c2c Mon Sep 17 00:00:00 2001 From: structix Date: Thu, 11 Jul 2019 13:54:37 +0200 Subject: [PATCH] Update --- uebung10/api.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/uebung10/api.php b/uebung10/api.php index 7e0657c..cca969d 100644 --- a/uebung10/api.php +++ b/uebung10/api.php @@ -13,9 +13,9 @@ if (isset($_GET['n'])) { $questions = $db->getQuestions($n); $fullarray[] = []; -for ($i = 0; $i < count($questions); $i++) { - $answers[] = array($questions['answer0'], $questions['answer1'], $questions['answer2']); - $jsonarray[] = array("id" => $questions['id'], "answers" => $answers, "solution" => $questions['solution']); +foreach($questions as $q) + $answers[] = array($q['answer0'], $q['answer1'], $q['answer2']); + $jsonarray[] = array("id" => $q['id'], "answers" => $answers, "solution" => $q['solution']); $fullarray[] = $jsonarray; }