To get the top row(s) of a text file, you can use this method:
$lines=4;
$data="";
$fp=fopen("file.txt", "r");
while ($lines) {
$data.=fgets($fp, 1024);
$lines--;
}
fclose($fp);
To get the end of a file, you can open the file, seek to the end, and keep seeking back and reading in lines. That way, you don't have to read the whole file to get the last X lines. Reply if you need specifics - it's not tricky 😉