Search code examples
phpsyntaxsquare-bracket

PHP: Double square brackets after a variable?


echo $a['b']['b2'];

What does the value in the brackets refer to? Thanks.


Solution

  • This is an array.

    what you are seeing is

        <?php
        $a = array(
            'b' => array(
              'b2' => 'x'
            )
        );
    

    So in this case, $a['b']['b2'] will have a value of 'x'. This is just my example though, there could be more arrays in the tree. Refer to the PHP Manual