Reading specific line of a file in PHP

前端 未结 6 1566
攒了一身酷
攒了一身酷 2020-12-11 05:33

I am working on reading a file in php. I need to read specific lines of the file.

I used this code:

fseek($file_handle,$start);
while (!feof($file_ha         


        
6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-11 05:53

    Does this work for you?

    $file = "name-of-my-file.txt";
    $lines = file( $file ); 
    echo $lines[67]; // echos line 68 (lines numbers start at 0 (replace 68 with whatever))
    

    You would obviously need to check the lines exists before printing though. Any good?

提交回复
热议问题