Maximum filesize that can be opened by fopen()

Does anyone know if fopen() has a maximum size? I have a 3GB csv file, would it be able to open that so I can read through it?

very unlikely. Remember php scripts have a memory limit set in the php.ini file (called memory_limit).

This is the maximum size of file you will be able to read (actually less, since the script will use other memory resources too).

Actually Shaq, fopen doesn’t put the file into memory it streams the contents of the file. So in theory you can open a 3 GB file with fopen without a problem. As long as you work on the file in increaments you won’t need to worry about memory.

What do you mean by that?

I would assume logic means something along the lines of…

$rHandle = fopen('3gb.file', 'r');
while(false === feof($rHandle))
    $sSegment = fread($rHandle, 1024);
    //do what you wish with the 1024 byte string.

You only ever have 1024 bytes of data in memory at a time.

Thats what I thought he meant. Right now I am loading each line into an array. I need to change that.

If you’re building a huge array from the CSV file, then the size of the file itself won’t directly be the limiting factor but the size of the array. The latter will be kept in memory whereas, as mentioned above, the file itself can be read incrementally.