Reputation: 195
I would like to add a specific value of JSON in a variable and then print it.My code is:
$jd_user = json_decode($result);
print_r($jd_user);
I want to print the highlight of the above picture CU26943
I try :
$client=$jd_user->data->user;
echo $client;
But I receive error:
Trying to get property of non-object in (..)
Any suggestions? Thanks in advance.
Upvotes: 1
Views: 47
Reputation: 1694
The data is an array not an object. You should use:
$jd_user = json_decode($result);
$client=$jd_user->data[0]->user;
echo $client;
Upvotes: 2