Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting an objects property with slashes in it

Tags:

php

freebase

I'm getting a json result back from an api request to the freebase database. This is part of the object returned called $json. A var dump of $json:

stdClass Object
(
[name] => Abomey
[/location/statistical_region/population_growth_rate] => 
[/common/topic/article] => Array
    (
        [0] => stdClass Object
            (
                [id] => /m/0jk2c
            )
    )

How can I subtract the /m/0jk2c part?

$json->/common/topic/article[0]->id (obviously) doesn't work.

like image 559
stUrb Avatar asked Dec 27 '22 02:12

stUrb


1 Answers

This should do it:

$json->{"/common/topic/article"}[0]->id
like image 156
jeroen Avatar answered Dec 29 '22 16:12

jeroen