获取文件的内容,通过给出指向php [duplicate]的指针

i have a huge file, going upto 10 MB.

I want to load the file using php in chunks. Also the file should be loaded in reverse order.

what i want to do is, provide a to and from file pointers or byte sizes where 0 means the last position of the file.

so if i say

0 - 5000, it would mean load from position : last -5000 to last

5000 - 10000, it would mean load from position : last - 10000 to last - 5000

</div>

This may work for you?

//opens file
$ctx = fopen('file.txt', 'r');

//number of lines from end to read
$number = 5000;

//move to end of file - $number
fseek($ctx, $number, SEEK_END);

//loop until end of file
while(!feof($ctx))
{
    $buffer = fgets($ctx);
}

fclose($ctx);