Code: Select all
$id=1;
while(file_exists("folder/" . $id .".txt")) {
$txt_file = fopen($file, "r") or exit("Error");
$first_line = fgets($txt_file);
echo "The first line is ".$first_line;
$id++
}Also, I would like to know how to read the third line of the text file. To get the second line, I know you can read the first line (ie. fgets to \n) and find out how many bytes the first line is, then start the cursor at that offset to read the second line. A) there must be an easier way and B) if not how do I use this to read the thrid, fourth, sixth line etc. Is there a function anybody has written to readline(linenumber)?
Thanks!