Accessing and collecting post[] data from an array in PHP
I have a form like the one below which is posted to processForm.php, and the user can dynamically add more with jquery.
<input type="text" name="subject[]" />
<input type="text" name="grade[]" />
<input type="text" name="year[]" />
<input type="text" name="subject[]" />
<input type="text" name="grade[]" />
<input type="text" name="year[]" />
<input type="text" name="subject[]" />
<input type="text" name="grade[]" />
<input type="text" name="year[]" />
Please How can i access those arrays from subject[], grade[] and year[] inputs by the user?
Greg K posted this at 07:19 — 10th September 2014.
He has: 2,145 posts
Joined: Nov 2003
Assuming using POST instead of GET
$_POST['subject'][0]
$_POST['grade'][0]
$_POST['year'][0]
$_POST['subject'][1]
$_POST['grade'][1]
$_POST['year'][1]
$_POST['subject'][2]
$_POST['grade'][2]
$_POST['year'][2]
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.