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
Untested code, but should work:
$file = file("filename.txt"); for ($i = max(0, count($file)-6); $i < count($file); $i++) { echo $file[$i] . "\n"; }
Calling max will handle the file being less than 6 lines.
max