我在我的网站上使用 zillow api
{
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/"
}
}
}
}
}
}
}
以上是我从 Zillow Api 得到的响应,我从响应中获取了值,如下所示:
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
我使用下面的代码获得了这个:
$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";
}
}
现在我的问题是如何获得如下格式的单个值?
<li>zipid:48897608</li>
<li>low:374048</li>
<li>last-updated:03/12/2017</li>