title: Read and parse contents of very large file
body: <p>I am trying to parse a tab delimited file that is ~1GB in size.</p>
  
  <p>Where I run the script i get:</p>
  
  <pre><code>Fatal error: Allowed memory size of 1895825408 bytes exhausted  (tried to allocate 1029206974 bytes) ...
  </code></pre>
  
  <p>My script at the moment is just:</p>
  
  <pre><code>$file = file_get_contents('allCountries.txt') ;
  
  $file = str_replace(array("\r\n", "\t"), array("[NEW*LINE]", "[tAbul*Ator]"), $file) ;
  </code></pre>
  
  <p>I have set the memory limit in php.ini to -1, which then gives me:</p>
  
  <pre><code>Fatal error: Out of memory (allocated 1029963776) (tried to allocate 1029206974 bytes)
  </code></pre>
  
  <p>Is there anyway to partially open the file and then move on to the next part so less memory is used up at one time?</p>