Hello,
I have a text file that has searches logged to it and the number of results that are returned. How would I go about getting the last 5 or so lines in an array so I can display them on a page...?
Thanks in advance,
Tony.
Hi,
try something like this:
<?php
// Read all lines in an array. $all_lines = file('logfile.txt');
// This is the array which will contain the result. $last_lines = array_slice($all_lines, -5, 5);
?>
Cheers, Markus
also, you could change the logging feature to write new lines at the top of the file, then when retrieving them, you just read the first 5...
// Thomasson