I want to post unlimited form data to a JSON file in php. When I do this:
$vals = array(
array(
'quest' => $_POST['question'],
'a' => $_POST['answer_a'],
'b' => $_POST['answer_b'],
'c' => $_POST['answer_c'],
'd' => $_POST['answer_d'],
'correct' => $_POST['correct_answer']
)
);
the result for on post is:
[
{
"quest": "HI?",
"a": "no?",
"b": "yes?",
"c": "Maybe?",
"d": "Nah...",
"correct": "D"
}
]
But when I add multiple posts the result is:
[
{
"quest": "HI?",
"a": "no?",
"b": "yes?",
"c": "Maybe?",
"d": "Nah...",
"correct": "D"
}
][
{
"quest": "HI?",
"a": "no?",
"b": "yes?",
"c": "Maybe?",
"d": "Nah...",
"correct": "D"
}
]
How can I format the json data correctly on each post submit?