F
F
Fanil8772019-11-22 21:34:47
PHP
Fanil877, 2019-11-22 21:34:47

How to add a second rss feed?

Help me figure out how to connect a second rss feed. Here is the working code:

<?php

function utf8_convert($str, $type)
{
   static $conv = '';
   if (!is_array($conv))
   {
      $conv = array();
      for ($x=128; $x <= 143; $x++)
      {
         $conv['utf'][] = chr(209) . chr($x);
         $conv['win'][] = chr($x + 112);
      }
      for ($x=144; $x<= 191; $x++)
      {
         $conv['utf'][] = chr(208) . chr($x);
         $conv['win'][] = chr($x + 48);
      }
      $conv['utf'][] = chr(208) . chr(129);
      $conv['win'][] = chr(168);
      $conv['utf'][] = chr(209) . chr(145);
      $conv['win'][] = chr(184);
   }
   if ($type == 'w')
   {
      return str_replace($conv['utf'], $conv['win'], $str); 
   }
   elseif ($type == 'u')
   {
      return str_replace($conv['win'], $conv['utf'], $str);
   }
   else
   {
      return $str;
   }
}
$url = 'https://www.eyefootball.com/football_news.xml';       //адрес RSS ленты

$rss = simplexml_load_file($url);       //Интерпретирует XML-файл в объект

//цикл для обхода всей RSS ленты
foreach ($rss->channel->item as $item) {
 echo '<a href="'.$item->link.'">';
        echo '<h2>'.utf8_convert($item->title,"w").'</h2>';  //выводим на печать заголовок статьи 
 echo '</a>';
        echo utf8_convert($item->description,"w");   //выводим на печать текст статьи
}
?>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question