$line) { $temp = explode("_",$line); $temparr[$key][0] = $line; $temparr[$key][1] = $temp[0]; } // now iterate through $allissues, and grab ALL the issues. foreach($temparr as $key => $line) { $newissues[] = str_pad(roman2num($line[1]), 8, "0", STR_PAD_LEFT).".".$line[0]; } // sort the issues. this should sort on that first volume number, and sort them in ASCENDING order, so we'll absolutely get the right volume numbers. sort($newissues); // iterate through our current array and remove all the extraneous zeroes, as well as our sorting numbers! foreach($newissues as $key => $line) { // explode at the "." to retrieve our padded sort number. $line = explode(".",$line); // then ditch it by setting $line to just $line[1]. $line = $line[1]; // now replace out the zeroes that we put in way back when we first generated the sortable issue numbers. $line = str_replace('_00','_',$line); $line = str_replace('_0','_',$line); // this puts our edited $line into a new array. (what we work with in an iteration is basically a copy.) $newissues[$key] = $line; } // here's the timestamps for the various magazines. $subtractor is just an arbitrary number of days that will always give us the previous month but not TWO months back. if($magname == 'MaxChevy') { $firstissue = 1155661200; $subtractor = 17; } // August 15, 2006 if($magname == 'MoparMax') { $firstissue = 1154451600; $subtractor = 3; } // August 1, 2006 // this gets us all the stuff from the timestamp -- month, day, year. $firstdate = getdate($firstissue); // set these values, initially, to the first issue's publication values. $day = $firstdate['mday']; $month = $firstdate['mon']; $year = $firstdate['year']; //iterate through all the issues and sort out what date they should be archived, based on the value of $firstissue. foreach($newissues as $key => $line) { // Add one to the month. If that makes it not-a-month, set month to January and add one to the year. ++$month; if($month > 12) { $month = 01; ++$year; } // The first value in $temp[] is the value of $line, which is volume_issue. $temp[0] = $line; // pad out the month and day so that we always have two-digit values. $newm = str_pad($month, 2, "0", STR_PAD_LEFT); $newd = str_pad($day, 2, "0", STR_PAD_LEFT); // The second valud in $temp[] is the year.month.day, so something like 20060801 . It's concatenated in THIS ORDER for sorting and comparing. $temp[1] = $year.$newm.$newd; // Our $temp array is strictly internal to the loop; here we write it out into a multidimensional array. It's called $flippedissues because it's in the wrong order. $flippedissues[] = $temp; } // reverse the array so that we get everything in descending order. $allissues = array_reverse($flippedissues); // what day is it TODAY? Write that out in the same 20060801 format for comparison. $todaydate = getdate(); $thismtemp = str_pad($todaydate['mon'], 2, "0", STR_PAD_LEFT); $thisdtemp = str_pad($todaydate['mday'], 2, "0", STR_PAD_LEFT); $today = $todaydate['year'].$thismtemp.$thisdtemp; ?> MoparMax Archive


Interested in purchasing one of these back issue? Click here to order online!