user3681970 user3681970 - 1 year ago 143
JSON Question

parsing json with php curl

I have the following json :

{"returnCode":0,"returnMessage":"SUCCESS","data":{"OrganizationName":"ABC inc."}}

I wrote the following code to parse the organization name. But it is not working.

$response = json_decode($server_output, true);
foreach($response['data'] as $item)
echo $item['OrganizationName'];


Answer Source

No need to use foreach use below code to get OrganizationName

 $response = json_decode($server_output, true);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download