strago Posted February 17, 2010 Share Posted February 17, 2010 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.