Reading file PHP using too much memory -
so, i'm trying parse text file has 24mb , 314134 lines. problem is, feel script using way memory. this code: if(file_exists($filepath)) { $data = file_get_contents($filepath); $lines = explode("\n", $data); foreach ($lines $line) { //split line. $spllitedline = explode(';', utf8_encode($line)); //get fields index. $localidade = !empty($spllitedline[3]) ? $spllitedline[3] : ''; $codigo_postal = $spllitedline[14] . '-' . $spllitedline[15]; $morada = (!empty($spllitedline[5]) ? $spllitedline[5] : ' ') . ' ' . (!empty($spllitedline[6]) ? $spllitedline[6] : ' ') . ' ' . (!empty($spllitedline[7]) ? $spllitedline[7] : ' ') . ' ' . (!empty($spllitedline[8]) ? $spllitedline[8] : ' ') . ' ' . ...