It makes sense once you realize what's going on, but it's messy.
PHP:
$x['foo'] = 'foo';
As $x is uninitialized, the parser reads the [] as an array access and creates an $x as array of 'foo' => 'bar'
PHP:
$x['foo']['bar'] = 'bar';
$x is now initialized as an array but $x['foo'] is a string within that array so the second set of brackets treated as (rarely) used string accessors. 'bar' is a string that is silently casted to 0 as that is what the string accessor expects and the value of the first character $x['foo'] is set to 'b' (as a range wasn't specified).
It's an odd one, because you'd normally expect the code:
PHP:
$x['foo']['bar'] = 'bar';
To set a $x -> child_element (foo) -> child_element (bar) to bar. The correct code is actually:
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.