I have array like this
$result = "{
"datas": "www",
"data": {
"id": 1153
}
}";
$get = json_decode($result);
I want to get id in object data. I use $param = "data->id" but it doesn't work and I get an error Undefined property: stdClass::$data->id
, but if I get datas by using $param = "datas", it works.
to get data I use return $get->$param .
How to get id ? sorry for my english.
$resultis invalid, double quotes everywhere.$result, then useecho $get->data->id;to get the id, nothing to spectacular here. 3v4l.org/GCXU8$result = json_encode(array('datas' => 'www','data' => array('id' => 1153)));