I'm using PHP's array auto-index to structure my form data. Like:
<input name="users[][name]">
<input name="users[][name]">
<input name="users[][name]">
When I post this data PHP will automatically create an array for users
under $_POST
.
But what if we need to add another field to each user, like:
<li>
<input name="users[][name]">
<input name="users[][nickname]">
</li>
<li>
<input name="users[][name]">
<input name="users[][nickname]">
</li>
<li>
<input name="users[][name]">
<input name="users[][nickname]">
</li>
Of course, the code above will create 6 entries instead of the desired 3 user entries.
Is there any way to access users[]
(the last added entry) without increment it?