I'm working on a form that allows a user to create their own surveys. Each survey has n number of questions, and n number of answers per question.
For example (Not tested this form, just an example):
<form action="/add-survey" method="POST">
<label for="question_1">Question 1</label>
<input type="text" name="question[]">
<ul id="answers">
<li class="answer">
<label for="answer_1">Answer 1</label>
<input type="text" name="...."> /* What do I do here? */
</li>
</ul>
</form>
When I submit the form, in the PHP script I would like to access the forms like so:
$_POST['question'][0]['answer'][0] // Question 1, answer 1
If I set the name attribute to answer[] I end up with two arrays question and answer, which makes it difficult to work with.
Is this possible at all?