Jump to content

Newest log first, and 'fuzy math.'


strago

Recommended Posts

define("DOWNLOADS_FILE","/public_html/downloads.html");

$downloadsEntry = "<center><A HREF=http://www.domain.com/v/$v/>$v</a><HR></center>\n";

$lines = file(DOWNLOADS_FILE);
$lines[] = $downloadsEntry;
$last40 = array_slice($lines, -40);
file_put_contents(DOWNLOADS_FILE, implode("", $last40));
    {
        $downloadsFile = fopen(DOWNLOADS_FILE,"a");
    }
//    fwrite($downloadsFile,$downloadsEntry);
    fclose($downloadsFile);

 

This logs the last 20 downloads. The newest download is added at the bottom of the file. How do you change it so the newest log is added at the top of the file, so it's listed first using

 

echo <<< END
  <H1>Last 20 Downloads</H1>
END;
  include('downloads.html');

 

And how do you make it so '20' actually means '20'? Right now you have to have '40' to get '20' logs.

Link to comment
https://forums.phpfreaks.com/topic/192328-newest-log-first-and-fuzy-math/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.