Multidimensional Arrays
| From: | Ed Curtis | Date: | Mon, 20 Oct 2003 18:38:57 +0000 |
| Subject: | Multidimensional Arrays | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-166794@lists.php.net to get a copy of this message | ||
I'm trying to submit multiple values to a variable within an <option>
tag by using a value such as value="this,that" There are multiple <select>
statements on this form each counting up from 1 using $count and
$listings as such.
<? $count = 1;
$listings = 3
while ($count <= $listings) {?>
<select name="listings[<? echo $count; ?>" value="1">
<option value="this,that">This and That
<option value="that,this">That and This
<? $count++; } ?>
On the recieving side I'm parsing many instances of these using the
following method
$count = 1;
$listings = 3;
while ($count <= $listings) {
$listing['$count'] = $_POST['listing[$count]'];
}
This example works fine if I need to get the full value (this,that) or
(that,this). What I'd like to do is break this into a multidimensional
array so I have approximately the following depending on what they choose
for each example.
$listing[1][0] = this
$listing[1][1] = that
$listing[2][0] = that
$listing[2][0] = this
Hopefully this example is clear enough that someone will understand what
I'm doing. I tried the following with no luck.
$listing['count'] = $_POST['listing[count]'];
$listing['$count'] = explode(",", $listing['$count']);
Any takers? Thanks.
Ed