Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP: Double square brackets after a variable?

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

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

like image 576
Bobby Avatar asked Nov 02 '25 23:11

Bobby


1 Answers

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

like image 171
Marc Steven Plotz Avatar answered Nov 04 '25 12:11

Marc Steven Plotz