I'm trying to get the right results from looping through rows generated when calling a function in php but i only get one row generated not all the rows. Below code of what i have.
<form method="post" action="done.php">
<div id="add_passenger">
<div class="fields">
<input type="text" name="field[email]" />
<input type="text" name="field[name]" />
</div>
<button type="button" onclick='add_field_row();' ">Add Email</button>
<input type="submit" value="submit" />
</div>
</form>
$dynamicEmailFields = $_POST['field']
<?php
foreach($test as $key => $fields) {
//Here i want to output the field name and value depending on the
number of row generated when calling add_field_row() For instance:
email1: [email protected]
name1: john doe
email2: [email protected]
name2: john doe
//With this result from the loop it means that there were 2 rows generated.
}
?>
name="field[email][]"andname="field[name][]"ORname="field[0][email]"andname="field[0][name]"