logiacer logiacer - 22 days ago 8
JSON Question

cURL PHP Getting value of JSON

Response:

{
"error":null,
"value1":"STRING",
"valuelist":{
valueurl:{
"status":STATUS_TEXT,
},
}
}


cURL:

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $response);

curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_POST, false);

curl_setopt($ch, CURLOPT_TIMEOUT, 3);

$content = curl_exec ($ch);

curl_close ($ch);

return $content;


now I have json_decoded it, I can't get value of "status".

echo $foo->value1; works fine.

echo $foo->status; isn't right. How would I get that value?

Answer

The value of status should be access like below:

$foo->valuelist->valueurl->status