我需要链接到我的下拉菜单中的外部网站,该菜单中包含每周五更改文件名的pdf。我以前曾问过这个问题,但我是php的初学者,所以我很难实现它。任何帮助将不胜感激。
实施例
www.extranet.frostyacres.com/portal_resources/1/Market Report 05-24-13.pdf
www.extranet.frostyacres.com/portal_resources/1/Market Report 05-31-13.pdf
www.extranet.frostyacres.com/portal_resources/1/Market Report 06-07-13.pdf
www.extranet.frostyacres.com/portal_resources/1/Market Report 06-14-13.pdf
我试图在html文件的下拉菜单中使用它,不确定是否可能。
$startingDate = strtotime('2013-06-07');
echo '<a href="https://www.extranet.frostyacres.com/portal_resources/1/Market Report ' . date('m-d-y', $startingDate) . '.pdf">Market Reports</a>';
答案 0 :(得分:1)
您可以使用:
echo Date('m-d-y', strtotime("Last Friday"));
要显示上周五,然后添加您想要显示的周五数量的次数(-7),如下所示:
function display_last_fridays($n) {
for ($i=0;$i<$n;$i++) {
echo Date('m-d-y', strtotime($i*-7 . " days Last Friday")) . "<br/>";
}
}
display_last_fridays(5);
答案 1 :(得分:0)
<?php
// all fridays from startingdate till NOW
$display_only_the_most_recent_friday = false; // all fridays or most recent only
$startingDate = strtotime('2013-01-01'); // lets test from start of 2013
$start = time(); // now
$end = $startingDate; // our loop will $start from now and scan back till the $end
// we will check every day from $start to $end
// in every loop we are going one day back -=(60 * 60 * 24)
for($checkdate=$start;$checkdate>=$end; $checkdate -=(60 * 60 * 24))
{
if ( date('N', $checkdate) == "5" ) // and if this day is the fifth day we echo
{
echo '<a href="https://www.extranet.frostyacres.com/portal_resources/1/Market Report '.date('m-d-y', $checkdate).'.pdf">Market Reports</a>';
if($display_only_the_most_recent_friday)
break;
}
}
?>
(它显示最新的第一个)