[php] how to read only 5 last line of the txt file
- by safaali
hello
i have a file named "file.txt"
it updates by adding lines to it.
I am reading it by this code:
$fp = fopen("file.txt", "r");
$data = "";
while(!feof($fp))
{
$data .= fgets($fp, 4096);
}
echo $data;
and a huge number of lines appears.
I just want to echo the last 5 lines of the file
how can i do that ?
thanks in advanced