0

I have a big text file (like 10.000 row). Im trying to fix memory problems. I'm using this code, to read every row from my text file.

$handle = fopen("votes.txt", "r") or die("Couldn't get handle");
if ($handle) 
{
    while (!feof($handle))
    {
        $buffer = fgets($handle, 4096);
        echo $buffer."</br>";
    }
    fclose($handle);
}

When i read the file, is taking too much time, and i guess taking too much memory. Any solution to reading this file line by line. Important: i dont want to read all rows at the same time, i want to read line by line.

0 Answers0