PHP is choking because it's running out memory. Instead of having curl populate a PHP variable with the contents of the file, use the
option to save the file to disk instead.
//pseudo, untested code to give you the idea $fp = fopen('path/to/save/file', 'w'); curl_setopt($ch, CURLOPT_FILE, $fp); curl_exec ($ch); curl_close ($ch); fclose($fp);
Then, once the file is saved, instead of using the
file_get_contents functions (which would load the entire file into memory, killing PHP again), use
fopen and fgets to read the file one line at a time.