I am creating a form where a user can input certain information. The default state looks as following;
<div class="options">
<input type="text" name="option[]" />
<input type="text" name="content[]" />
</div>
Now, by clicking a button ADD, I will add two new fields with the same name so the state is as follows;
<div class="options">
<input type="text" name="option[]" />
<input type="text" name="content[]" />
<input type="text" name="option[]" />
<input type="text" name="content[]" />
</div>
Then, I want PHP to eventually create a string as below;
valueOfFirstOption:valueOfFirstContent,valueOfSecondOption:valueOfSecondContent
And so on, and so on. Theoretically I should be able to add an infinite amount of input fields.
Is this possible what I am trying to achieve? Or should I be adding unique names to the input fields?
Any tips or hints how I should be going? Or somebody got a tutorial/example code for me?
Thanks in advance.