0

I am using zillow api on my website

{
request: {
address: "13546 36th Ave NE",
citystatezip: "Seattle, WA"
},
message: {
text: "Request successfully processed",
code: "0"
},
response: {
results: {
result: {
zpid: "48897608",
links: {
homedetails: "http://www.zillow.com/homedetails/13546-36th-Ave-NE-Seattle-WA-98125/48897608_zpid/",
graphsanddata: "http://www.zillow.com/homedetails/13546-36th-Ave-NE-Seattle-WA-98125/48897608_zpid/#charts-and-data",
mapthishome: "http://www.zillow.com/homes/48897608_zpid/",
comparables: "http://www.zillow.com/homes/comps/48897608_zpid/"
},
address: {
street: "13546 36th Ave NE",
zipcode: "98125",
city: "Seattle",
state: "WA",
latitude: "47.727631",
longitude: "-122.289193"
},
zestimate: {
amount: "393735",
last-updated: "03/12/2017",
oneWeekChange: {
@attributes: {
deprecated: "true"
}
},
valueChange: "24606",
valuationRange: {
low: "374048",
high: "413422"
},
percentile: "0"
},
localRealEstate: {
region: {
@attributes: {
name: "Cedar Park",
id: "271831",
type: "neighborhood"
},
zindexValue: "547,700",
links: {
overview: "http://www.zillow.com/local-info/WA-Seattle/Cedar-Park/r_271831/",
forSaleByOwner: "http://www.zillow.com/cedar-park-seattle-wa/fsbo/",
forSale: "http://www.zillow.com/cedar-park-seattle-wa/"
}
}
}
}
}
}
}

Above is the response that i am getting from Zillow Api, I have fetched the values from the response, Something like below:

zpid => 48897608
links:
homedetails => http://www.zillow.com/homedetails/13546-36th-Ave-NE-Seattle-WA-98125/48897608_zpid/
graphsanddata => http://www.zillow.com/homedetails/13546-36th-Ave-NE-Seattle-WA-98125/48897608_zpid/#charts-and-data
mapthishome => http://www.zillow.com/homes/48897608_zpid/
comparables => http://www.zillow.com/homes/comps/48897608_zpid/
address:
street => 13546 36th Ave NE
zipcode => 98125
city => Seattle
state => WA
latitude => 47.727631
longitude => -122.289193
zestimate:
amount => 393735
last-updated => 03/12/2017

I obtained this using code below:

$jsonIterator = new RecursiveIteratorIterator(
    new RecursiveArrayIterator(json_decode($json, TRUE)),
    RecursiveIteratorIterator::SELF_FIRST);

foreach ($jsonIterator as $key => $val) {
    if(is_array($val)) {
        echo "$key:\n";
    } else {
        echo "$key => $val\n";
    }
}

Now my question is how can get single values like in format below?

<li>zipid:48897608</li>
<li>low:374048</li>

<li>last-updated:03/12/2017</li>
Raman
  • 624
  • 5
  • 13
  • Fatal error: Cannot use object of type RecursiveIteratorIterator as array – Raman Mar 14 '17 at 10:24
  • @C0dekid Are the braces(`{}`) needed ?? – Ayush Mar 14 '17 at 10:25
  • $jsonIterator = new RecursiveIteratorIterator( new RecursiveArrayIterator(json_decode($json, TRUE)), RecursiveIteratorIterator::SELF_FIRST); echo $jsonIterator['low']; this is what i am using now. – Raman Mar 14 '17 at 10:26
  • @Ayush Read here what the difference is: http://stackoverflow.com/questions/2596837/curly-braces-in-string-in-php :) – node_modules Mar 14 '17 at 10:27
  • @C0dekid I didn't know that. Thanks for sharing. :) – Ayush Mar 14 '17 at 10:29
  • @Ayush it gives error. – Raman Mar 14 '17 at 10:39