-2

I need to link to an external site in my drop down menu that hosts a pdf that changes file name every Friday. I had previously asked this question but I am a beginner to php so I am having a tough time implementing it. Any help would be greatly appreciated.

Ex.

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

I have tried to use this in a drop down menu in an html file, not sure if thats possible.

$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>';

?

4

2 回答 2

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);
于 2013-06-15T15:54:32.950 回答
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;
        }
    }

?>

它的工作http://3v4l.org/N3cQW

(它首先显示最新的)

于 2013-06-15T15:49:47.433 回答