0

我无法打印出 json 中包含的数据,这是我的代码:

$string='{
   "tonysacaoficial": {
      "id": "379656405412890",
      "about": "Candidato presidencial por UNIDAD, ex presidente de El Salvador y l\u00edder pol\u00edtico y empresarial\n\n",
      "app_id": "0",
      "can_post": false,
      "category": "Politician",
      "checkins": 0,
      "cover": {
         "cover_id": 556803864364809,
         "source": "http://sphotos-h.ak.fbcdn.net/hphotos-ak-prn2/s720x720/182904_556803864364809_1932672241_n.png",
         "offset_y": 0,
         "offset_x": 40
      },
      "has_added_app": false,
      "hometown": "Usulut\u00e1n",
      "is_community_page": false,
      "is_published": true,
      "likes": 24166,
      "link": "http://www.facebook.com/tonysacaoficial",
      "name": "Tony Saca",
      "talking_about_count": 4615,
      "username": "tonysacaoficial",
      "website": "https://twitter.com/tonysacaoficial",
      "were_here_count": 0
   }
}';
$json = array(json_decode($string));
//print_r($json[0]);


        echo "items:". $json[0]->id ."\n";

我需要显示 json 中包含的数据(id、source 和 likes)

4

1 回答 1

1

查看您需要做的 json 字符串

echo "items:". $json[0]->tonysacaoficial->id ."\n";
于 2013-05-22T16:02:30.217 回答