I have the following PHP that displays the month then an IF statement inside the foreach that says IF the month is February then do the li:
$months = array('1' => 'January', '2' => 'February', '3' => 'March', '4' => 'April', '5' => 'May', '6' => 'June', '7' => 'July', '8' => 'August', '9' => 'September', '10' => 'October', '11' => 'November', '12' => 'December');
echo '<li><a class="by_month"></a><ul class="monthby" name="monthby">';
foreach($months as $month => $monthtitle):
if ($month == '2'){
echo '<li title="'.$monthtitle.'" rel="'.$month.'"><a href="#" title="'.$monthtitle.'">'.$monthtitle.'</a></li>';
}
endforeach;
echo '</ul></li>';
How do I modify the above code to say IF the month is February, then exclude any previous months. Basically, I want to create a list of the current month and upcoming months but exclude past months of the year.
So, for example, if the month was November, the list would ONLY show November and December. It would exclude all previous months.
How can I do this? I image I need to do something with an IF statement, like I sort of started but using date('n') to get the current month then ignore previous months of the current month.
Any help?
Make the Array Keys to Ints and compare them with date(‘n’) (n stands for month without a prefix zero)