function readLine($sfile, $offset, $limit = 1000) {
$file = new SplFileObject($sfile);
$file->seek($offset);
$i = 1;
$data = array();
if ($limit == -1) {//read from line $offset to EOF
while (!$file->eof()) {
$line = $file->current(); $i++; $file->next();
processData($line, $data);
}
} else {
while (!$file->eof() && $i <= $limit) {
$line = $file->current(); $i++; $file->next();
processData($line, $data);
}
}
Title:
Read $limit lines from line $offset by PHP
Description:
function readLine($sfile, $offset, $limit = 1000) { $file = new SplFileObject($sfile); $file->seek($offset); $i = 1; $dat...
...
Rating:
4