Reputation: 490
I fetched some data using JSON. Then I converted the result to PHP Array using json_decode(). Now, I am trying to get some value. I am getting notices.
$html = $curl->get($url); // $html contains json result
$result = json_decode($html); //converting to php array
//the output is something like this
{
"query":
"results":{
"Result":[
{
"BusinessUrl":"http://www.aplus.net/",
-----------
------------
}]
}
Now, if I try to fetch the business url like this
$result->query->results->Result[0]->BusinessUrl
which gives notices like
Notice: Trying to get property of non-object
Please help me in this.
Upvotes: 0
Views: 139
Reputation: 5490
Try
$result->query->results->Result[0]['BusinessUrl']
My guess is once you hit an array in JSON you're stuck accessing everything from an array instead of an object.
Upvotes: 1