1. Is It Possible To Count Number Of Lines In A File Without Creating An Array 2. How To Move File Pointer To A Specified Line
For the number of lines: $lines = substr_count (file_get_contents ('filename.txt'), "\n"); PHP: In order to set the file pointer to a specific line, you are going to need to calculate where that line starts (in bytes). You may need to loop the strpos() function (with the optional offset parameter) once for each line to ultimately figure out that value.
I just remembered how you can get the offsets of each carriage return without looping... preg_match_all ("#\\n#", file_get_contents('filename.txt'), $matches, PREG_OFFSET_CAPTURE); print_r ($matches); PHP: