I have a very large text file with over 100,000 lines in it. I need to collect/skip a set number of lines: loop through lines 1-100, skip lines 101-150, read lines 151-210, skip lines 211-300 (for example).
I have the following code
$lines = file('file.txt');
$counter = 0;
foreach ($lines as $lineNumber => $line) {
$counter++;
if ($counter < 101) {
//Do update stuff
}
if ($counter < 102 && $counter > 151) {
//Skip these lines
}
if ($counter < 152 && $counter > 211) {
//Do update stuff
}
}
Is there a better way to skip over many lines of an array's output?
fread