【发布时间】:2011-01-15 04:13:35
【问题描述】:
这是我从提要查找器 url(JSON 编码)得到的字符串:
{
"updated": 1265787927,
"id": "http://www.google.com/reader/api/0/feed-finder?q\u003dhttp://itcapsule.blogspot.com/\u0026output\u003djson",
"title": "Feed results for \"http://itcapsule.blogspot.com/\"",
"self": [{
"href": "http://www.google.com/reader/api/0/feed-finder?q\u003dhttp://itcapsule.blogspot.com/\u0026output\u003djson"
}],
"feed": [{
"href": "http://itcapsule.blogspot.com/feeds/posts/default"
}]
}
如何使用 php 中的 json_decode() 函数对其进行解码并获取最后一个数组元素(“feed”)?我用下面的代码试过了,但没有运气
$json = file_get_contents("http://www.google.com/reader/api/0/feed-finder?q=http://itcapsule.blogspot.com/&output=json");
$ar = (array)(json_decode($json,true));
print_r $ar;
请帮忙..
【问题讨论】:
-
抱歉,如果我误解了,但您不想要 $ar['feed'] 吗?
-
PHP 中不需要类型转换。
-
@Jasonbar,是的,你是正确的。我只需要“feed”值。
-
(array)前面的json_decode()是不需要的。而且没有任何作用。