title: rss feed with images using php
body: <p>I am trying to pull an rss feed through for the following rss feed
  <a href="http://menmedia.co.uk/manchestereveningnews/news/rss.xml" rel="nofollow">http://menmedia.co.uk/manchestereveningnews/news/rss.xml</a></p>
  
  <p>I can pull this through no problem using this method:</p>
  
  <pre><code>&lt;?
  $xml = file_get_contents('http://menmedia.co.uk/manchestereveningnews/news/rss.xml');
  
  // Use cURL to get the RSS feed into a PHP string variable.
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL,
          'http://menmedia.co.uk/manchestereveningnews/news/rss.xml');
  curl_setopt($ch, CURLOPT_HEADER, false);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  $xml = curl_exec($ch);
  curl_close($ch);
  
  // Include the handy XML data extraction functions.
  include 'xml_regex.php';
  // An RSS 2.0 feed must have a channel title, and it will
  // come before the news items. So it's safe to grab the
  // first title element and assume that it's the channel
  // title.
  $channel_title = value_in('title', $xml);
  // An RSS 2.0 feed must also have a link element that
  // points to the site that the feed came from.
  $channel_link = value_in('link', $xml);
  
  // Create an array of item elements from the XML feed.
  $news_items = element_set('item', $xml);
  
  foreach($news_items as $item) {
      $title = value_in('title', $item);
      $url = value_in('link', $item);
      $description = value_in('description', $item);
      $timestamp = strtotime(value_in('pubDate', $item));
      $item_array[] = array(
              'title' =&gt; $title,
              'url' =&gt; $url,
              'description' =&gt; $description,
              'timestamp' =&gt; $timestamp
      );
  }
  
  if (sizeof($item_array) &gt; 0) {
      // First create a div element as a container for the whole
      // thing. This makes CSS styling easier.
      $html = '';
      // Markup the title of the channel as a hyperlink.
      $html .= '';
      // Now iterate through the data array, building HTML for
      // each news item.
      $count = 0;
      echo "";
      foreach ($item_array as $item) {
           $html .= '&lt;a href="'.make_safe($item['url']).'" target="_blank"&gt;
      &lt;img src="'.$item['enclosure'].'"&gt;
      '.substr("".$item['title']."", 0, 80).' 
  
      &lt;/div&gt;&lt;/a&gt;';
  
  
  
          echo '';
          // Limit the output to five news items.
          if (++$count == 1) {
              break;
          }
  
      }
      $html .= '';
      echo $html;
  }
  
  function make_safe($string) {
      $string = preg_replace('#&lt;!\[CDATA\[.*?\]\]&gt;#s', '', $string);
      $string = strip_tags($string);
      // The next line requires PHP 5, unfortunately.
      //$string = htmlentities($string, ENT_NOQUOTES, 'UTF-8', false);
      // Instead, use this set of replacements in PHP 4.
      $string = str_replace('&lt;', '&amp;lt;', $string);
      $string = str_replace('&gt;', '&amp;gt;', $string);
      $string = str_replace('(', '&amp;#40;', $string);
      $string = str_replace(')', '&amp;#41;', $string);
      return $string;
  }
  
  
  ?&gt;
  </code></pre>
  
  <p>However I am trying to get the images to also pull through which are in the enclosure tag on the rss feed.</p>
  
  <p>At the minute i am using :</p>
  
  <pre><code>&lt;img src="'.$item['enclosure'].'"&gt;
  </code></pre>
  
  <p>This isnt working.</p>
  
  <p>Any ideas would be really appreciated!</p>
  
  <p>thanks</p>