I pulled some data from my database. Is working perfectly. But I want to remove the double quotes in the JSON. Here are my codes;
$sql = "SELECT id, instructions, quiz_question, correct, wrong, wrong1, wrong2 FROM student_quiz WHERE subject = 'SOCIAL STUDIES' AND type = 'challenge'";
$results = $pdo->query($sql);
$results->setFetchMode(PDO::FETCH_ASSOC);
$json = [];
while($row = $results->fetch()) {
$choices = [
$row['correct'],
$row['wrong'],
$row['wrong1'],
$row['wrong2'],
];
// shuffle the current choices so the 1st item is not always obviously correct
shuffle($choices);
$json[] = [
'question' => $row['quiz_question'],
'choices' => $choices,
'correctAnswer' => $row['correct'],
];
}
echo json_encode($json);
Is echoing a data like this;
{"question":"Who said this statement \"Ghana your beloved country is free for ever\"?
<\/p>","choices":["Jack Chan","Donald Trump","Ato Ahoi","Kwame Nkrumah"],"correctAnswer":"Kwame Nkrumah"}
But I want it like this:
{question:"Who said this statement \"Ghana your beloved country is free for ever\"?
<\/p>",choices :["Jack Chan","Donald Trump","Ato Ahoi","Kwame Nkrumah"],correctAnswer :"Kwame Nkrumah"}