Enge Enge - 26 days ago 8
JSON Question

JSON Decode (PHP)

how can I Select the value of "success" from that json?:

{
"response": {
"success": true,
"groups": [
{
"gid": "3229727"
},
{
"gid": "4408371"
}
]

}
}


Thats my current code:

$result = json_decode ($json);
$success = $result['response'][0]['success'];
echo $success;


Thank you.
Regards

Answer

You are almost near to solution. place "true" as second argument for json_decode().

Eg: $result = json_decode ($json, true); $result['response']['success']; -> to get the value of success.