PHP File Tips - Part 3: We can read file at particular byte ranges. With this tips, you can use for seeking particular byte ranges. For this job, we combine fopen(), fseek(), fgetc(), and ftell().
<?
$file = "test.txt";
$start = 2;
$finish = 20;
$f = fopen($file, "rb");
fseek($f, $start, SEEK_SET);
while(!(ftell($f) > $finish)){
$data .= fgetc($f);
}
fclose($f);
echo $data;
// result:
// st line 1 test lin
?>