求教,php解析json的问题
本帖最后由 easeyoo 于 2014-01-16 23:15:20 编辑 各位大神,求教一下,网站返回的json数据如下:
{
"dataList": [
{
"Subject": "这里是标题",
"Distance": "距离",
"Address": "山东省青岛市"
},
{
"Subject": "这里是标题",
"Distance": "距离",
"Address": "山东省青岛市"
}
]
}
<?php
url = 'http://www.123.com/query_json.php?action=ceshi&x=1';
$response = ihttp_get($url); //ihttp_get是一个封装的函数,提交url的,没有任何问题
$content = $response['content'];
$d = json_decode($content, true);
$traces = $traces['dataList'];
foreach($traces as $trace) {
$reply .= "{$trace['Subject']} - {$trace['Address']}\n";
}
return $this->respText($reply);
}
return $this->respText($text);
?>