silasslack wrote:$exportfile = file_get_contents("sql_output.txt");
$lines = explode("\n",$exportfile);
At this point the entire line will be in memory twice - once as a single string, and once as an array of strings. [man]file[/man] will reduce one step, but if memory consumption really is a concern there's
$fp = fopen('sql_output.txt', 'rb');
while(!feof($fp))
{
$line = trim(fgets($fp));
if($line=='') continue;
// Do whatever it is you do with the line.
}
fclose($fp);
Then you only ever have one line of the file in memory at a time.
Another possibility, depending on the format of the text file (SQL?) is to have the database itself read the file directly and not get PHP involved at all.