Jump to content

[SOLVED] List months in reverse order


dc_jt

Recommended Posts

Hi Im looking to list all months of the year in reverse order for example for this month it will list like

 

November

October

September

August

July

June

May

April

March

Feb

Jan

December

 

I have done the following which gets it in normal order Jan-Dec:

 

 
$mnths = array('','January','February','March','April','May','June','July','August','September','October','November','December');

<?php  for ($i=1;$i<=12;$i++) {?>
                   
                     <li><a href="<?=$_SERVER['PHP_SELF']?>?iMonth=<?=$i?>"><?=$mnths[$i]?></a></li>              
                     <?php }?>  

 

Anyone help?

 

Thanks

Link to comment
Share on other sites

Its ok I got it using

 

                  <?php
for($i = 0;$i<12;$i++){
$time = strtotime("today - $i months");?>
<li><a href="<?=$_SERVER['PHP_SELF']?>?iMonth=<?=date("m",$time)?>"><?=date("M",$time)?></a></li>
<?php
}
?>   

 

Thanks anyway

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.