Reading specific line of a file in PHP

前端 未结 6 1551
攒了一身酷
攒了一身酷 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 06:05

    Try this,the simplest one

    $buffer=explode("\n",file_get_contents("filename"));//Split data to array for each "\n"
    

    Now the buffer is an array and each array index contain each lines; To get the 5th line

    echo $buffer[4];
    

提交回复
热议问题