Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用API通过简单的html dom解析器将url解析为数组_Php_Parsing - Fatal编程技术网

Php 使用API通过简单的html dom解析器将url解析为数组

Php 使用API通过简单的html dom解析器将url解析为数组,php,parsing,Php,Parsing,我在启动“部族社区统计”项目时遇到问题。 我对统计的API有一个很好的理解,我想用一个简单的HTMLDOM解析器在数组中显示这一点。我想得到这样的效果: { "status": "ok", "count": 1, "data": { "1": { "members_count": 100, "description": "Закрытый клан...", "description_html": "<p>Закрыты

我在启动“部族社区统计”项目时遇到问题。 我对统计的API有一个很好的理解,我想用一个简单的HTMLDOM解析器在数组中显示这一点。我想得到这样的效果:

{
  "status": "ok", 
  "count": 1, 
  "data": {
    "1": {
      "members_count": 100, 
      "description": "Закрытый клан...", 
      "description_html": "<p>Закрытый клан....\n</p>", 
      "created_at": 1293024672, 
      "updated_at": 1375930001, 
      "name": "Wargaming.net", 
      "abbreviation": "WG", 
      "emblems": {
        "large": "http://cw.worldoftanks.ru/media/clans/emblems/clans_1/1/emblem_64x64.png", 
        "small": "http://cw.worldoftanks.ru/media/clans/emblems/clans_1/1/emblem_24x24.png", 
        "medium": "http://cw.worldoftanks.ru/media/clans/emblems/clans_1/1/emblem_32x32.png", 
        "bw_tank": "http://cw.worldoftanks.ru/media/clans/emblems/clans_1/1/emblem_64x64_tank.png"
      }, 
      "clan_id": 1, 
      "members": {
        "196632": {
          "created_at": 1293126248, 
          "role": "private", 
          "updated_at": 1375930001, 
          "account_id": 196632, 
          "account_name": "Wrobel"
        }, 
        "18458": {
          "created_at": 1360836543, 
          "role": "diplomat", 
          "updated_at": 1375930001, 
          "account_id": 18458, 
          "account_name": "alienraven"
        }, 
        "3100": { ....
        }
      }, 
      "motto": "Орлы! Орлицы!", 
      "clan_color": "#e18000", 
      "owner_id": 1277137
    }
  }
}
接下来我应该做什么来准备一个数组并以我想要的方式在我的网页上显示它?有人愿意向我解释吗?求你了


你好Mary

我看到数据是json格式的。只需使用:

$json  =  file_get_contents('http://api.worldoftanks.eu/2.0/clan/info/?application_id=d0a293dc77667c9328783d489c8cef73&clan_id=500009659'); //gets the json
$obj = json_decode($json); //decode the json into object or array. You'll get an object
var_dump($obj); //view the object. Parse the object the way you want to.
试试这个

<?php
// example of how to modify HTML contents
include('../simple_html_dom.php');

// get DOM from URL or file
$html = file_get_html('http://api.worldoftanks.eu/2.0/clan/info/?application_id=d0a293dc77667c9328783d489c8cef73&clan_id=500009659');

$data = json_decode($html);

echo "<pre>";
print_r($data);
?>

<?php
// example of how to modify HTML contents
include('../simple_html_dom.php');

// get DOM from URL or file
$html = file_get_html('http://api.worldoftanks.eu/2.0/clan/info/?application_id=d0a293dc77667c9328783d489c8cef73&clan_id=500009659');

$data = json_decode($html);

echo "<pre>";
print_r($data);
?>