I have a file named file.txt which is update by adding lines to it.
file.txt
I am reading it by this code:
$fp = fopen(\"file.txt\", \"r\"); $da
If your lines are separated by a CR or LF you would try exploding your $data variable:
$lines = explode("\n", $data);
$lines should end up being an array and you can work out the number of records using sizeof() and just get the last 5.