Accessing elements within an object that contain characters not permitted under PHP's naming convention (e.g. the hyphen) can be accomplished by encapsulating the element name within braces and the apostrophe.
Voorbeeld:
$json = '{"foo-bar": 12345}'; $obj = json_decode($json);
Fout:
echo $obj->foo-bar;
Goed:
echo $obj->{'foo-bar'};
Meer informatie: Hyphen
Categorieën
PHP