<?php
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
echo "<h2>Answers for participants</h2>";
for($index=0;$index < count($_POST['participant']); $index++) { echo "<p>{$_POST['participant'][$index]['name']} {$_POST['participant'][$index]['surname']}</p>";
for($qindex=0;$qindex < count($_POST['participant'][$index]['questions']); $qindex++) {
$id = $_POST['participant'][$index]['questions'][$qindex];
foreach($id['question_id'] as $key => $question) {
echo "<p>Question ID: $key answer {$question['answer']}</p>";
}
}
}
}
?>
<form method="post">
<h6>Participant - 1 - general</h6>
<div class="form-group font-size-sm">
<label for="namegeneral_1"
class="text-gray">Name</label>
<input type="text" required id="namegeneral_1"
name="participant[0][name]"
class="form-control" value="Jerry">
</div>
<div class="form-group font-size-sm">
<label for="surnamegeneral_1"
class="text-gray">Surname</label>
<input type="text" required id="surnamegeneral_1"
class="form-control"
name="participant[0][surname]" value="Bostick">
</div>
<div class="form-group">
<label for="participant_question">Phone</label>
<input type='phone' name='participant[0][questions][][question_id][1][answer]' class='form-control' value="909-188-7522" >
<!-- Pretend additional question for meal -->
<input type='text' name='participant[0][questions][][question_id][5][answer]' class='form-control' value="Steak" >
</div>
<input type="hidden" name="participant[1][rtypes]" value="1"/>
<h6>Participant - 2 - general</h6>
<div class="form-group font-size-sm">
<label for="namegeneral_2"
class="text-gray">Name</label>
<input type="text" required id="namegeneral_2"
name="participant[1][name]"
class="form-control" value="Tammy">
</div>
<div class="form-group font-size-sm">
<label for="surnamegeneral_2"
class="text-gray">Surname</label>
<input type="text" required id="surnamegeneral_2"
class="form-control"
name="participant[1][surname]" value="Wallace">
</div>
<div class="form-group">
<label for="participant_question">Phone</label>
<input type='phone' name='participant[1][questions][][question_id][1][answer]' class='form-control' value="909-872-1232" >
<!-- Pretend additional question for meal -->
<input type='phone' name='participant[1][questions][][question_id][5][answer]' class='form-control' value="Chicken" >
<input type="hidden"
name="participant_question_required[]"
value="1">
<input type="hidden"
value="1"
name="participant[1][][question_id]"/>
</div>
<input type="hidden" name="participant[2][rtypes]" value="1"/>
<input type="submit" class="btn btn-primary" value="Register"/>
</form>