Home › Forums › Back End › Multi Array Form › Re: Multi Array Form
December 12, 2009 at 6:33 pm
#68054
Member
Hey,
I normally do it like these :
First, simply do as AshtonSanders said.
Code:
This will make a name array and a description array when the data is sent over POST.
This should be the POST you would get :
Code:
Array
(
[name] => Array
(
[0] => Name 1
[1] => Name 2
[2] => Name 3
)
(
[name] => Array
(
[0] => Name 1
[1] => Name 2
[2] => Name 3
)
[description] => Array
(
[0] => Description 1
[1] => Description 2
[2] => Description 3
)
)
Then, on the PHP side, you can do something like this :
Code:
$value)
{
echo “Name “.($key+1).” : “.$names[$key].”n”;
echo “Description “.($key+1).” : “.$descs[$key].”n”;
echo “—-n”;
}
?>
{
echo “Name “.($key+1).” : “.$names[$key].”n”;
echo “Description “.($key+1).” : “.$descs[$key].”n”;
echo “—-n”;
}
?>
or this : (essentially the same, but this one is cleaner)
Code:
So, you have two equally created arrays and each individual Key on the Names array corresponds to the Key on the Descriptions array.
So anyways, i hope this helps!
Cheers =)