Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can use the following conditional statement to check if it's a Wednesday:</p> <pre><code>if ( date('l', strtotime($feed[$x]['date']) ) == 'Wednesday') { # code ... } </code></pre> <p>For checking if it's September:</p> <pre><code>if ( date('F', strtotime($feed[$x]['date']) ) == 'September') { # code ... } </code></pre> <hr> <p>Full code:</p> <pre><code>&lt;?php $rss = new DOMDocument(); $rss-&gt;load('http://www.anewmandesigns.com/oakshade/calendar/rss/RSSseptember2013.xml'); $feed = array(); foreach ($rss-&gt;getElementsByTagName('item') as $node) { $item = array ( 'title' =&gt; $node-&gt;getElementsByTagName('title')-&gt;item(0)-&gt;nodeValue, 'desc' =&gt; $node-&gt;getElementsByTagName('description')-&gt;item(0)-&gt;nodeValue, 'link' =&gt; $node-&gt;getElementsByTagName('link')-&gt;item(0)-&gt;nodeValue, 'date' =&gt; $node-&gt;getElementsByTagName('pubDate')-&gt;item(0)-&gt;nodeValue, ); //echo date('l', strtotime($item['date']))."\n"; array_push($feed, $item); } $limit = 5; for($x=0;$x&lt;$limit;$x++) { if ( date('l', strtotime($feed[$x]['date']) ) == 'Wednesday') { // if it is wednesday, proceed $title = str_replace(' &amp; ', ' &amp;amp; ', $feed[$x]['title']); $link = $feed[$x]['link']; $description = $feed[$x]['desc']; $year = date('Y', strtotime($feed[$x]['date'])); $month = date('M', strtotime($feed[$x]['date'])); $day = date('d', strtotime($feed[$x]['date'])); echo '&lt;p&gt;'.$month.'&lt;span&gt; '.$day.'&lt;/span&gt;&lt;/p&gt;'; echo '&lt;p&gt;&lt;a href="'.$link.'" title="'.$title.'"&gt;'.$description.'&lt;/a&gt;&lt;/p&gt;'; } } ?&gt; </code></pre> <p>Notes:</p> <ul> <li><p>Note that you didn't have the <code>$timestamp</code> variable defined anywhere and I've changed it to get the year directly from the <code>pubDate</code> field. </p></li> <li><p>In the XML file you posted, there aren't any items posted on Wednesday, so the above code would not output anything, but if you change it to a different week day, it should work.</p></li> <li><p>The current XML file's dates are all in September, so I've avoided the conditional check in the code, but if you want to check the month as well, you can add it.</p></li> </ul> <p>Hope this helps!</p>
 

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