That's normal. It's a PHP parser "bug" - it's not greedy when looking for arrays in strings:
$arr[1][2] = 'foo';
echo "$arr[1][2]"; non-greedy
echo $arr[1][2]; greedy, outputs 'foo'
is parsed as
echo $arr[1], "[2]";
^^^^^^^--array
^^^^--string
output: Array[2]
Echoing an array in string context will always output the literal word Array
, and not the array's contents.
Using the {}
notation forces PHP to suck in the entire array reference:
echo "{$arr[1][2]}"; // outpus "foo";
The "bug" applies to both normal ""
-quoted strings, and HEREDOCs.