Unable to access value of nested array element

Posted by John Conde on Stack Overflow See other posts from Stack Overflow or by John Conde
Published on 2010-04-01T13:16:49Z Indexed on 2010/04/01 13:23 UTC
Read the original article Hit count: 361

I'm having an issue getting the value of a nested array element. Here's what I've got:

print_r($environment);

// Outputs
Array
(
    [0] => Array
        (
            ['parameter'] => Vibration
            ['conditions'] => 204
            ['method'] => D
        )

    [1] => Array
        (
            ['parameter'] => Immersion
            ['conditions'] => 104
            ['method'] => B
        )

    [2] => Array
        (
            ['parameter'] => Shock
            ['conditions'] => 213
            ['method'] => I
        )

    [3] => Array
        (
            ['parameter'] => Humidity
            ['conditions'] => 106
            ['method'] => -
        )
)


print_r($environment[0]);

// Outputs
Array
(
    ['parameter'] => Vibration
    ['conditions'] => 204
    ['method'] => D
)


echo $environment[0]['parameter'];

// Nothing

Maybe I've been looking at this for too long. Any ideas would be greatly appreciated.

© Stack Overflow or respective owner

Related posts about php

Related posts about arrays