Re: There Has to be an easier way (Multidimensional Array_
| From: | Adam Voigt | Date: | Tue, 03 Dec 2002 16:13:09 +0000 |
| Subject: | Re: There Has to be an easier way (Multidimensional Array_ | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-126879@lists.php.net to get a copy of this message | ||
An important thing to note in general, if you do:
<input name="address[][address]" value="test1">
<input name="address[][city]" value="test2">
<input name="address[][state]" value="test3">
On the page your submitting to, you'll end up with:
$address[0][address]
$address[1][city]
$address[2][state]
Where as you were expecting to get:
$address[0][address]
$address[0][city]
$address[0][state]
This happens because when you use the [] operator
to say to PHP "next array position", every time it hits
that it increments the row, rather then understanding
your trying to say "set this value on this array row", it
hears "woah, I just saw a [] so I'm going to up the row".
--
Adam Voigt (adam@cryptocomm.com)
The Cryptocomm Group
My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc
Attachment: [application/pgp-signature] This is a digitally signed message part signature.asc
Attachment: [application/pgp-signature] This is a digitally signed message part signature.asc