0

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.

4 Answers 4

4

try this

echo $_POST['opt'][0][0];
Sign up to request clarification or add additional context in comments.

Comments

2

Try this,

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

Because opt is in $_POST

Comments

1

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.

1 Comment

What an unbelievably stupid error to have made. Sorry! And thank you
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.