如何解码这个JSONstring?
这是我从一个饲料查找器URL(JSON编码)得到的string:
{"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()函数,并获得最后一个数组元素(“饲料”)? 我试了下面的代码,但没有运气
  $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; 
请帮忙 ..
 $array = json_decode($json, true); $feed = $array['feed']; 
 请注意, json_decode()在作为第二个参数调用true时已经返回一个数组。 
更新:
 作为JSON中的feed的值 
 "feed":[{"href":"http://itcapsule.blogspot.com/feeds/posts/default"}] 
 是一个对象数组, $array['feed']是: 
 Array ( [0] => Array ( [href] => http://itcapsule.blogspot.com/feeds/posts/default ) ) 
 要获得URL,您必须使用$array['feed'][0]['href']或$feed[0]['href']来访问数组。 
但这是数组的基本处理。 也许arrays文档可以帮助你。