Note that there are some explanatory texts on larger screens.

plurals
  1. POWhen parsing RSS feed, wrong date is displayed
    primarykey
    data
    text
    <p>Here is my code:</p> <pre><code>&lt;?php $RSSFEEDS = array( 0 =&gt; "http://samnabi.posterous.com/rss.xml", ); function FormatRow($date, $title, $link, $description) { return &lt;&lt;&lt;HTML &lt;p class="blogdate"&gt;$date&lt;/p&gt;&lt;h2 class="blogtitle"&gt;$title&lt;/h2&gt; &lt;div class="clearer"&gt;&amp;nbsp;&lt;/div&gt; $description HTML; } ob_start(); if (!isset($feedid)) $feedid = 0; $rss_url = $RSSFEEDS[$feedid]; $rss_feed = file_get_contents($rss_url); $rss_feed = str_replace("&lt;![CDATA[", "", $rss_feed); $rss_feed = str_replace("]]&gt;", "", $rss_feed); $rss_feed = str_replace("\n", "", $rss_feed); $rss_feed = preg_replace('#&lt;image&gt;(.*?)&lt;/image&gt;#', '', $rss_feed, 1 ); preg_match_all('#&lt;pubDate&gt;(.*?)&lt;/pubDate&gt;#', $rss_feed, $date, PREG_SET_ORDER); preg_match_all('#&lt;title&gt;(.*?)&lt;/title&gt;#', $rss_feed, $title, PREG_SET_ORDER); preg_match_all('#&lt;link&gt;(.*?)&lt;/link&gt;#', $rss_feed, $link, PREG_SET_ORDER); preg_match_all('#&lt;description&gt;(.*?)&lt;/description&gt;#', $rss_feed, $description, PREG_SET_ORDER); if(count($title) &lt;= 1) { echo "No new blog posts. Check back soon!"; } else { for ($counter = 1; $counter &lt;= 3; $counter++ ) { if(!empty($title[$counter][1])) { $title[$counter][1] = str_replace("&amp;", "&amp;", $title[$counter][1]); $title[$counter][1] = str_replace("&amp;apos;", "'", $title[$counter][1]); $row = FormatRow($date[$counter][1],$title[$counter][1],$link[$counter][1],$description[$counter][1]); echo $row; } } } ob_end_flush(); ?&gt; </code></pre> <p>When this script is run, the first item displays the second item's <strong>pubDate</strong>. The second item displays the third item's <strong>pubDate</strong>, and so on. So the dates that are shown are not the dates that you see in the original XML file. How do I fix this?</p> <p>Bonus question: how do I strip characters off the beginning and end of the <strong>pubDate</strong> tag, so that I end up with "15 May 2010" instead of "Sat, 15 May 2010 03:28:00 -0700" ? </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload