Get the content of the file right up to the given line number.
string $filename The name of the file to load.:
int $lineNumber The number of lines to read from file.:
string The content of the file.
private function getFileContent($filename, $lineNumber) {
$content = '';
$lineCnt = 0;
$file = new SplFileObject($filename);
while (!$file
->eof()) {
if ($lineCnt++ == $lineNumber) {
break;
}
$content .= $file
->fgets();
}
return $content;
}