title: Is there a more efficient way to write this PHP/jQuery
body: <p>I have this PHP:</p>
  
  <pre><code>&lt;?php
  
  $data = file_get_contents('http://newsrss.bbc.co.uk/rss/sportonline_uk_edition/football/rss.xml');
  
  $xml = simplexml_load_string($data);
  
  $data1 = file_get_contents('http://www.skysports.com/rss/0,20514,11661,00.xml');
  
  $xml1 = simplexml_load_string($data1);
  
  $master[0] = $xml;
  $master[1] = $xml1;
  
  echo json_encode($master);
  
  ?&gt;
  </code></pre>
  
  <p>And this jQuery:</p>
  
  <pre><code>    var myRSS =[];
  
  function rssReader() {
  
      console.log('ran');
  
      $.getJSON('bbc.php', function(data){
          console.log(data);
          $.each(data[0].channel.item, function(index, item){
              // check if item title is stored in the array   
              if (jQuery.inArray(item.title, myRSS) != -1) { 
                  //do nothing
              } else {
                  // save item title in the array
                  myRSS.push(item.title);
  
                  // publish item  
                  $('.container').prepend("&lt;a target='_BLANK' href='" + item.link + "' class='title' data-date='" + item.pubDate + "'&gt;" + item.title + "&lt;/a&gt;");
                  $("title").text('EMG: ' + item.title);
                  $('#loader').remove();
              }
          });
  
          $.each(data[1].channel.item, function(index, item){
              // check if item title is stored in the array   
              if (jQuery.inArray(item.title, myRSS) != -1) { 
                  //do nothing
              } else {
                  // save item title in the array
                  myRSS.push(item.title);
  
                  // publish item  
                  $('.container').prepend("&lt;a target='_BLANK' href='" + item.link + "' class='title' data-date='" + item.pubDate + "'&gt;" + item.title + "&lt;/a&gt;");
                  $("title").text('EMG: ' + item.title);
              }
          });
  
      });
  
  }
  
  rssReader();
  
  setInterval(rssReader, 10000);
  </code></pre>
  
  <p>There seems to be a lot of repeated code and therefore isn't very DRY programming. The returned JSON actually has the same structure, from BBC and Sky Sports so there must be a more efficient way of writing this.</p>
  
  <p>Thanks</p>