I have a large amount of data (1,948,280 bytes) that I tried to write out to a file 
using

if ($fp = fopen($file,"w")):

            fwrite($fp,$contents,strlen($contents));

fclose($fp);

endif;





and got "Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to 
allocate 1948281 bytes)" on the 2nd line. So, I tried to write out smaller portions 
with:

if ($fp = fopen($file,"w")):

            $size = 4096;

            while (strlen($contents)){

                        $temp = substr($contents,0,$size);

                        fwrite($fp,$temp,$size);

                        $contents = substr($contents,$size+1);

            }

            fclose($fp);

endif;

but get a similar error on the line "$contents = substr($contents,$size+1);" which is 
what I'm using to try to avoid running out of memory. It appears that I can't replace 
the variable with a smaller version of itself. 

So, if I can't write out the whole thing and can't section it either, what can I do?

Jeff



---------------------------------
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now

Reply via email to