PHP: Read Specific Line From File

后端 未结 12 650
天命终不由人
天命终不由人 2020-11-28 08:15

I\'m trying to read a specific line from a text file using php. Here\'s the text file:

foo  
foo2

How would I get the content of the seco

12条回答
  •  被撕碎了的回忆
    2020-11-28 08:53

    $myFile = "4-21-11.txt";
    $fh = fopen($myFile, 'r');
    while(!feof($fh))
    {
        $data[] = fgets($fh);  
        //Do whatever you want with the data in here
        //This feeds the file into an array line by line
    }
    fclose($fh);
    

提交回复
热议问题