Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/243.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.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 统计合并rss源中的项目标记_Php_Xml_Rss_Simplexml - Fatal编程技术网

Php 统计合并rss源中的项目标记

Php 统计合并rss源中的项目标记,php,xml,rss,simplexml,Php,Xml,Rss,Simplexml,我试图从RSS提要列表中计算标题标签 $urls = "http://www.engadget.com/rss.xml"; $xml = simplexml_load_file($urls); $tags = array(); foreach($xml->channel->item as $item) { $children = $item->title; foreach ($children as $node) { $tags[] = $n

我试图从RSS提要列表中计算标题标签

$urls = "http://www.engadget.com/rss.xml";
$xml = simplexml_load_file($urls);
$tags = array();
foreach($xml->channel->item as $item) {
  $children = $item->title;
  foreach ($children as $node) {
    $tags[] = $node->getName();
  }
}
$count= array_count_values($tags);

echo '<pre>';
print_r($count);
$url=”http://www.engadget.com/rss.xml";
$xml=simplexml\u加载文件($url);
$tags=array();
foreach($xml->channel->item as$item){
$children=$item->title;
foreach($子节点作为$节点){
$tags[]=$node->getName();
}
}
$count=数组\计数\值($tags);
回声';
打印(计数);

在上面这样做。。。它可以工作,但是如果我有多个URL呢。我该怎么做呢?

将URL放在一个数组中,然后在URL数组中来回移动,基本上完成您已经在做的事情

$url=[”http://www.engadget.com/rss.xml","http://www.engadget.com/rss.xml"];
$tags=array();
foreach($url作为$url){
$xml=simplexml\u加载文件($url);
foreach($xml->channel->item as$item){
$children=$item->title;
foreach($子节点作为$节点){
$tags[]=$node->getName();
}
}
}
$count=数组\计数\值($tags);
回声';
打印(计数);

您必须将这些代码中的一部分放入一个循环中。您希望计数是来自多个URL的所有标记吗?或者每个URL的标记计数我希望它是来自多个URL的所有标记。它工作得很好
$urls = ["http://www.engadget.com/rss.xml","http://www.engadget.com/rss.xml"];

$tags = array();
foreach ( $urls as $url ) {
    $xml = simplexml_load_file($url);
    foreach($xml->channel->item as $item) {
        $children = $item->title;
        foreach ($children as $node) {
            $tags[] = $node->getName();
        }
    }
}

$count= array_count_values($tags);

echo '<pre>';
print_r($count);