The PHP parser is not greedy. {} Used to indicate what should be considered part of a variable reference and what not. Consider this:
$arr = array(); $arr[3] = array(); $arr[3][4] = 'Hi there'; echo "$arr[3][4]";
Pay attention to double quotes. You expected this to output Hi there , but actually you see Array[4] . This is due to the frivolity of the analyzer. It will check only one level of indexing the array when interpolating variables into a string, so this was really visible:
echo $arr[3], "[4]";
But by doing
echo "{$arr[3][4]}";
forces PHP to treat everything inside curly brackets as a variable reference, and you get the expected Hi there .
source share