I have a few dynamicaly build input fields in a form that looks like this:
<input type="text" class="form-control" name="person[]" placeholder="Person" />
<input type="text" class="form-control" name="function[]" placeholder="Function" />
<input type="text" class="form-control" name="person[]" placeholder="Person" />
<input type="text" class="form-control" name="function[]" placeholder="Function" />
<input type="text" class="form-control" name="person[]" placeholder="Person" />
<input type="text" class="form-control" name="function[]" placeholder="Function" />
Because i write my input name like this: person[] & function[] i get an numeric indexed array in my $_POST array.
Because the input fields are made dynamicaly it is never known for sure how many person[] & function[]index numbers there will be in the $_POST.
How do i handle this? In other words what if i would like to INSERT person[0] + function[0] & person[1] + function[1] + ... (variable amount of person's & their functions) into my database? how could i extract this so it is possible to do this?
NOTE: Every person has his own function so it is important that it stays together.
I did not got very far so i cannot provide more code i have tried:
foreach ($_POST['person'] as $value){
...
}
This gives me a list of that specific array person[] inside of the $_POST but this isn't usefull to me..
countfunction?+ add morethat involves javascript?