Re: There Has to be an easier way (Multidimensional Array_
| From: | Dev | Date: | Tue, 03 Dec 2002 16:01:32 +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-126878@lists.php.net to get a copy of this message | ||
Thank you That works great!
At 11:56 PM 12/3/2002 +0800, Jason Wong wrote:
On Tuesday 03 December 2002 23:45, Dev wrote: Hello all Currently I have a web fom that has 3 field in it that I want writing to a multidimensional array. <TR><TD><INPUT TYPE="text" NAME="address[]" VALUE=""></TD> <TD WIDTH="50" ALIGN="center"><INPUT TYPE="text" NAME="address[]['state']"VALUE="" SIZE="5" MAXLENGTH="5"></TD><TD COLSPAN="2"><INPUT TYPE="text" NAME="address[][]['zip']"VALUE=""></TD> </TR> I would name them as: NAME="address[][address]" NAME="address[][state]" NAME="address[][zip]" (I'm assuming you have multiple addresses on a single form) Then loop through them by: foreach ($address as $key => $value) {echo "Address: {$value['address']} State: {$value['state']} Zip:{$value['zip']}"; } For a single address use: NAME="address[address]" NAME="address[state]" NAME="address[zip]" And no need to loop, just use the values directly. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* The best portion of a good man's life, his little, nameless, unremembered acts of kindness and love.-- Wordsworth*/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php