I am having trouble understanding this problem.

I have defined a multidimensional array but cannot echo values from it.

print_r($_POST) gives this:

Array
(
[title] => zxfvsdf
[purchaseDecision] => on
[optcolumn] => 2
[optrow] => 2
[opt] => Array
    (
        [0] => Array
            (
                [0] => asd
            )

        [1] => Array
            (
                [0] => 123
            )

        [2] => Array
            (
                [0] => vbn
            )

        [3] => Array
            (
                [0] => yui
            )

    )

)

But echo $opt[0][0] returns 'undefined variable: opt'.

I am sure I am missing something quite basic...

Any help is greatly appreciated.

share|improve this question
up vote 4 down vote accepted

try this

echo $_POST['opt'][0][0];
share|improve this answer

Try this,

print_r($_POST['opt'][0][0]);

Because opt is in $_POST

share|improve this answer

it should be: $_POST['opt'][0][0];

if the register_globals is disabled in php (which is a good thing and is by default disabled) variables are not assigned from the request.

share|improve this answer
    
What an unbelievably stupid error to have made. Sorry! And thank you – kadeshiseraph Jul 5 '13 at 10:10

Define $opt = $_POST['opt']; before using $opt[0][0]

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.