I have a form which field can have multiple instances. Like for example the contact field. The user can add one or more contacts.
Now, when the form is submitted, I want it to send the data like this:
contact[0][type] contacts[0][value] --- first instance contacts[1][type] contacts[1][value] --- second instance contacts[2][type] contacts[2][value] --- third instance and so on..
So that in my code, I can loop them like this:
$contacts = $_POST['contacts'];
foreach($contacts as $contact){
echo $contact['type'] . '<br>';
echo $contact['value'] . '<br>';
echo '--------------------------';
}
Is it even possible? Or can you suggest a better way to do this?