Using a multi-dimensional array in a POST form?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have a lot of data I want to associate with a single line item in table of
data. The current method (which feels messy to me) is to do this....

<INPUT TYPE=HIDDEN VALUE="range_1" NAME="userange[1111]">
<INPUT TYPE=HIDDEN VALUE="scanner_1" NAME="usescanner[1111]">
<INPUT TYPE=HIDDEN VALUE="record_1" NAME="userecord[1111]">

<INPUT TYPE=HIDDEN VALUE="range_2" NAME="userange[2222]">
<INPUT TYPE=HIDDEN VALUE="scanner_2" NAME="usescanner[2222]">
<INPUT TYPE=HIDDEN VALUE="record_2" NAME="userecord[2222]">

Which gives me this:

_POST[userange] => Array
(
    [1111] => range_1
    [2222] => range_2
)
_POST[usescanner] => Array
(
    [1111] => scanner_1
    [2222] => scanner_2
)
_POST[userecord] => Array
(
    [1111] => record_1
    [2222] => record_2
)

What I'd like to do is this:

<INPUT TYPE=HIDDEN VALUE="range_1" NAME="device[1111][range]">
<INPUT TYPE=HIDDEN VALUE="scanner_1" NAME="device[1111][scanner]">
<INPUT TYPE=HIDDEN VALUE="record_1" NAME="device[1111][record]">

<INPUT TYPE=HIDDEN VALUE="range_2" NAME="device[2222][range]">
<INPUT TYPE=HIDDEN VALUE="scanner_2" NAME="device[2222][scanner]">
<INPUT TYPE=HIDDEN VALUE="record_2" NAME="device[2222][record]">

When I submit the form, it appears to work as illustrated by this print_r():

_POST[device] => Array
(
    [1111] => Array
        (
            [range] => range_1
            [scanner] => scanner_1
            [record] => record_1
        )

    [2222] => Array
        (
            [range] => range_2
            [scanner] => scanner_2
            [record] => record_2
        )
)

However, I don't seem to be able to access the elements?!

I've tried various combinations of tick marks on both the hidden input and
also on the retrieval to no avail...

Ie. 	<INPUT TYPE=HIDDEN VALUE="range_2" NAME="device[2222]['range']">

And 	echo "device[2222][range] = ".$device[2222]['range'];
or	echo "device[2222][range] = ".$device[2222][range];

Is this possible?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux