php read large text file log

后端 未结 5 1734
时光说笑
时光说笑 2020-12-10 22:04

I have a text log file, about 600 MB.

I want to read it using php and display the data on a html page, but I only need the last 18 lines that were added each time I

5条回答
  •  误落风尘
    2020-12-10 22:38

    you can stream it backwards with

    $file = popen("tac $filename",'r');
    
    while ($line = fgets($file)) {
      echo $line;
    }
    

提交回复
热议问题