Reputation: 48798
I am POSTing a multidimensional array with the following fields in a HTML form:
Member Name:
<input name="teamMembers[<?php echo $i; ?>][Name]" type="text"
id="teamMemberName1" maxlength="30" />
Email:
<input name="teamMembers[<?php echo $i; ?>][Email]" type="text"
id="teamMemberEmail1" maxlength="100" size="40" />
I can print_r($_POST['teamMembers']);
and see the contents of the array, but when I try echo $_POST['teamMembers[0][Name]'];
I get an "undefined index" error.
What am I doing wrong? (I'm sure it's something silly.)
Upvotes: 1
Views: 1845
Reputation: 382806
You have wrong syntax:
echo $_POST['teamMembers[0][Name]'];
Should be:
echo $_POST['teamMembers'][0]['Name'];
More Info about Arrays in PHP.
Upvotes: 11