PHP: Read Specific Line From File

后端 未结 12 663
天命终不由人
天命终不由人 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 09:12

    $myFile = "4-24-11.txt";
    $lines = file($myFile);//file in to an array
    echo $lines[1]; //line 2
    

    file — Reads entire file into an array

提交回复
热议问题