title: Using IF-ELSE statements to alter elements in a SimplePie feed based on their source
body: <p>I'm using SimplePie to combine various RSS feeds, and I want to control the output of each individual feed item based on the source for that item. My ultimate goal is to be able to control the content and style of an item based on where its coming from.</p>
  
  <p>I'm using the code below to sort feed items based on their the source link. Then, based on the source, I want to include the appropriate snippet of PHP to dictate which content to pull.</p>
  
  <pre><code>&lt;?php foreach ($feed-&gt;get_items($start,$length) as $item):
  
      if ($item-&gt;get_feed()-&gt;get_link()=="http://example.com/FeedURL1"):
              include 'includes/FeedSource1.html';
  
      elseif ($item-&gt;get_feed()-&gt;get_link()=="http://example.com/FeedURL2"):
              include 'includes/FeedSource2.html';
  
      elseif ($item-&gt;get_feed()-&gt;get_link()=="http://example.com/FeedURL3"):
              include 'includes/FeedSource3.html';
  
      else:
              echo '&lt;li&gt;fail&lt;/li&gt;';
      endif;
  
  endforeach; ?&gt;
  </code></pre>
  
  <p>Here's the problem I'm encountering: the first "if" statement works fine if an item is TRUE, but if it is FALSE, then it defaults to the final "else" statement, apparently bypassing the "elseif" statements that are in between.</p>
  
  <p>I've tested different items in the first "if" statement, so I know that my source detection code is working, but anything that is placed after an "elseif" is automatically ignored.</p>
  
  <p>I've looked everywhere to figure out what's wrong here, and from what I can tell I'm using the correct formatting for if/else statements. It's likely I'm making a silly parse error or something, as I'm fairly new to PHP. But any help/advice would be much appreciated!</p>
  
  <p><em>Example snippet that I would include for an item based on the feed source:</em></p>
  
  <pre><code>&lt;li&gt;
  &lt;a href="&lt;?php echo $item-&gt;get_permalink(); ?&gt;"&gt;
  &lt;?php echo substr($item-&gt;get_title(), 0, 250) . ''; ?&gt;
  &lt;br&gt;&lt;span&gt; &lt;?php echo $item-&gt;get_date('m.d.y / g:ia'); ?&gt;&lt;/span&gt;&lt;/a&gt;
  &lt;/li&gt;
  </code></pre>
  
  <p><em>For reference, here is the SimplePie code I'm using at the top of the page:</em></p>
  
  <pre><code>&lt;?php
  
  //get the simplepie library
  require_once('simplepie.inc');
  
  //grab the feed
  $feed = new SimplePie();
  
  $feed-&gt;set_feed_url(array(
      'http://example.com/FeedSource1.rss',
      'http://example.com/FeedSource2.rss',
      'http://example.com/FeedSource3.rss',
  ));
  
  //enable caching
  $feed-&gt;enable_cache(true);
  
  //provide the caching folder
  $feed-&gt;set_cache_location('cache');
  
  //set the amount of seconds you want to cache the feed
  $feed-&gt;set_cache_duration(600);
  
  //init the process
  $feed-&gt;init();
  
  //control how many feed items are shown
  $start = 0;
  $length = 25;
  
  //let simplepie handle the content type (atom, RSS...)
  $feed-&gt;handle_content_type();
  
  ?&gt;
  </code></pre>