check out what I've done at http://www.propertyinvestor.co.nz/rpimag/issues.php
The code below is hacked from a class I wrote and I use phplib template so it's hard to cut and paste meaningful code. But I need to dynamically display the issue list (I did this by hand for a year - got tiresome). To complicate things a month doesn't start on the 1st so I had to handle that.
You're on the right track.
var $abbrMonth = array( "dec", "feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec", "feb");
var $fullMonth = array( "December", "February","March","April","May","June","July","August","September","October","November","December","February");
function setCurrentIssue()
{
$days = date("d");
$month = date("n");
$year = date("y");
// force the month to be an integer, feb is 0, mar is 1, have to subtract 2 to get right month
if ($days < "05")
{ $month = $month - 2;}
else {$month = $month -1;}
if ($month < 1)
{$month = 11; $year = $this->givePrevYr($year);}
$fullMonth = $this->giveMonth($month);
$this->currentIssue = $fullMonth . $year ; //. $this->typeFile
}
function giveMonth($mthNo)
{
$output = $this->abbrMonth[$mthNo];
return $output;
} // function giveMonth
function giveFullMth($chkMth)
{
for ($i = 1; $i<12; $i++)
{
if ($chkMth == $this->abbrMonth[$i])
{
$output = $this->fullMonth[$i];
break;
}
}
return $output;
} // function giveFullMth