I am trying to wrap an entire form in an array. Currently looks like:
<div class="round">
<input name="points">
<input name="player1[]">
<input name="player2[]">
</div>
The entire form/div can be duplicated, so, ideally, I would have an output that could be spit out as
round[0][points]
round[0][player1[0,1,2]]
round[0][player2[0,1,2]]
It needs to be dynamic, so simply adding round[0] as static text before everything won’t work.
I have tried to wrap all of it in a , tried fieldset, but everything fails or spits out a terrible order of items.
Any ideas?
Edit to clarify desired output:
After all is said and done, I want this to be dynamic, hence the need for arrays within arrays. The output, after duplication, could be:
round[0][points]
round[0][player1[0,1,2]]
round[0][player2[0,1,2]]
round[1][points]
round[1][player1[0,1,2,3,4,5]]
round[1][player2[0,1,2,3,4,5]]
round[2][points]
round[2][player1[0,1]]
round[2][player2[0,1]]
You’re over thinking it simply add brackets after points like this:
When you go to process in it php just use a foreach loop:
Which should give you the results:
This should work (if I understand the question correctly).
EDIT:
Okay so I’m assuming the player1 & player2 input values are comma separated lists. If they are we just have to make an adjustment in the php:
Partial answer: this gets the “player” array into the “round” array, now I just have to figure out how to auto-increment the round[] like I want to:
But I think I could just use a counter for that… despite how much I hate counters.