title: Get enclosure img url from rss feed
body: <p>I have a problem with an rss feed in php. I want do get the img-url from "enclosure" but it´s not working.</p>
  
  <p>My code just now:</p>
  
  <pre><code>$rss = simplexml_load_file($url);
  
  $i = 0;
  if($rss)
  {
  $items = $rss-&gt;channel-&gt;item;
  foreach($items as $item)
  {
  $title = $item-&gt;title;
  $link = $item-&gt;link;
  $published_on = $item-&gt;pubDate;
  $phpDate = strtotime($published_on);
  $enclosure = $item['enclosure'][0]['url'];
  </code></pre>
  
  <p>From the RSS:</p>
  
  <pre><code>&lt;enclosure url="http://www.svenskafans.com/image/7/141433/Snalla-Pelle-stanna-i-Gefle.jpg" lenght="51265" type="image/jpeg" /&gt;
  </code></pre>
  
  <p>Important to note is that sometimes there is not enclosure-tag with so it must work even if it is missing.</p>
  
  <p>Thanks!
  Best Regards
  Charles</p>