title: How to check if a URL is a valid RSS feed in PHP
body: <p>I have the following code:</p>
  
  <pre><code>    function parse() {
          $content = file_get_contents($this-&gt;feed);        
          $rss = new SimpleXmlElement($content);
          $rss_split = array();
          $i = 0;
          foreach ($rss-&gt;channel-&gt;item as $item) {
              $title = (string) $item-&gt;title; // Title
              $link = (string) $item-&gt;link; // Url Link            
              $content = $item-&gt;children('content', true)-&gt;encoded;
              preg_match('/&lt;img.+src=[\'"](?P&lt;src&gt;.+)[\'"].*&gt;/i', $content, $image);
              $image = substr($image['src'], 0, strpos($image['src'], '"'));
              $rss_split[$i]['title'] = $title;
              $rss_split[$i]['link'] = $link;
              $rss_split[$i]['image'] = $image;
              $i++;
          }
          return $rss_split;
      }
  </code></pre>
  
  <p>Here, <code>$this-&gt;feed</code> contains the RSS feed's URL. The problem is I do not know how to validate the URL to be sure it is a valid RSS feed.</p>