I\'d just come across a very weird bit of php code:
$oink{\'pig\'} = 1;
var_dump($oink);
$oink{\'pig\'} = \'123123\';
echo $oink{\'pig\'}; /* => 123123 *
It is mentioned in the manual. {}
is just an alternative syntax to []
§:
Both square brackets and curly braces can be used interchangeably for accessing array elements (e.g.
$array[42]
and$array{42}
will both do the same thing in the example above).
The same goes the strings §:
Characters within strings may be accessed and modified by specifying the zero-based offset of the desired character after the string using square array brackets, as in
$str[42]
. Think of a string as an array of characters for this purpose. [...]Note: Strings may also be accessed using braces, as in
$str{42}
, for the same purpose.