Skip to content
Advertisement

Parse a nested JSON in PHP

I have a nested JSON which looks likes this:

JavaScript

And I want to obtain the “pincode” from the given JSON, Since I am new to PHP I am facing a litte difficulty in parsing the JSON file. I have tried something like this,

JavaScript

NOte that the $response is an XML response which I am converting to JSON. An I am getting this error:

JavaScript

Help is appreciated

Advertisement

Answer

Since you are parsing the json to an array, you access the pincode like this:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement