I am trying to figure out the best way to name my HTML form fields so that they can be easily parsed into a set of PHP opbjects.
For example I have the following table of elements: (let's assume it is inside a form)
<table>
<tr id='payment0'>
<td><input type='text' name='paymentType0'></td>
<td><input type='text' name='paymentAmount0'></td>
<td><input type='text' name='paymentAccount0'></td>
</tr>
<tr id='payment1'>
<td><input type='text' name='paymentType1'></td>
<td><input type='text' name='paymentAmount1'></td>
<td><input type='text' name='paymentAccount1'></td>
</tr>
</table>
Obviously I can write a bunch of code to search through the $_POST array to find all the paymentType/Amount/Account etc. values and put them into objects. However this feels a bit smelly and I am wondering if there is a better way to name these form elements?
On a side note, I had attempted to name the fields as control arrays (at least that's what I call them) so instead of paymentType0 it would be paymentType[0] and PHP would see them as an array that I could iterate though. The problem with this approach is that referencing these fields with jQuery becomes very difficult due to the square brackets.
What's the 'best of both' worlds solution for this?