// set up the path $dir = dirname(__FILE__) . "/research-daily/rd-teasers/"; // set the end date to today and format (dates will be in descending order) $end = date("Y/m/d"); // set the start date to today minus 21 days $start = date('Y-m-d', strtotime('-21 days')); // make sure the array includes today's date range $date = date('Y-m-d', strtotime('+1 days')); // today plus 1 day // create the array of dates using the above variables $weekOfdays = array(); for($i =1; $i <= 21; $i++){ $date = date('Y-m-d', strtotime('-1 day', strtotime($date))); $weekOfdays[] = date('Y-m-d', strtotime($date)) . ".inc"; } //scan files in a given diretory in descending order and create an array $filesarray = scandir($dir, 1); // limit the files array to 25 values $limitedarray = array_slice($filesarray, 0, 25); // compare the two previously created arrays (this will create a new array containing only matching values) $matchdatesarray=array_intersect($weekOfdays,$limitedarray); // reset the array keys $reindexedArray = array_values($matchdatesarray); //print_r($reindexedArray); // set the path for the includes $incspath = "/research//research-daily/rd-teasers/";
$story4 = $reindexedArray[3]; include($_SERVER['DOCUMENT_ROOT']. $incspath . $story4);
$story5 = $reindexedArray[4]; include($_SERVER['DOCUMENT_ROOT']. $incspath . $story5);
$story6 = $reindexedArray[5]; include($_SERVER['DOCUMENT_ROOT']. $incspath . $story6);