Home > Backend Development > PHP Tutorial > 求教,php解析json的有关问题

求教,php解析json的有关问题

WBOY
Release: 2016-06-13 12:30:08
Original
926 people have browsed it

求教,php解析json的问题

本帖最后由 easeyoo 于 2014-01-16 23:15:20 编辑 各位大神,求教一下,网站返回的json数据如下:
{<br />
    "dataList": [<br />
        {<br />
            "Subject": "这里是标题",<br />
            "Distance": "距离",<br />
            "Address": "山东省青岛市"<br />
        },<br />
        {<br />
            "Subject": "这里是标题",<br />
            "Distance": "距离",<br />
            "Address": "山东省青岛市"<br />
        }<br />
    ]<br />
}
Copy after login


在另一端,也是采用php的,使用了如下代码来获取,但是获取不到任何数据,代码如下:
<br />
<?php<br />
<br />
url = 'http://www.123.com/query_json.php?action=ceshi&x=1'; <br />
$response = ihttp_get($url); //ihttp_get是一个封装的函数,提交url的,没有任何问题<br />
$content = $response['content'];<br />
$d = json_decode($content, true);<br />
$traces = $traces['dataList'];<br />
foreach($traces as $trace) {<br />
	$reply .= "{$trace['Subject']} - {$trace['Address']}\n";	<br />
			}<br />
	return $this->respText($reply);<br />
}<br />
<br />
return $this->respText($text); <br />
?><br />
Copy after login


这样做无法输出结果,其中respText是一个封装的类,主要是一个微信引擎向用户返回数据的,请教如何才能获取到json返回的数据,谢谢了。
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template