huge file to load "file vs SplFileObject" in php

1k views Asked by At

I am trying to read a text file with 7 million lines hereby named HUGE. I am trying to read the first 10 thousand lines and then delete them. I am presently using SplFileObject like this...

    $file = new SplFileObject(FILENAME);
    for ($i = $start; $i <= $end; $i++) {
        $file->seek($i);
        $lines .= $file->current();
    }
    return($lines);

I do not yet have HUGE. I need to know if SplFileObject can load such a huge file. I need to calculate the length of HUGE every time I remove lines from it. "file" seems promising since count(array_HUGE) will give me the length immediately. I need to make a design decision now. Which of the 2 has a smaller footprint and is faster in loading HUGE?

0

There are 0 answers