title: Split a text file in PHP
body: <p>How can I split a large text file into separate files by character count using PHP? So a 10,000 character file split every 1000 characters would be split into 10 files. Further, can I split only after a full stop is found?</p>
  
  <p>Thanks.</p>
  
  <p>UPDATE 1: I like zombats code and I removed some errors and have come up with the following, but does anyone know how to only split after a full stop?</p>
  
  <pre><code>$i = 1;
      $fp = fopen("test.txt", "r");
      while(! feof($fp)) {
          $contents = fread($fp,1000);
          file_put_contents('new_file_'.$i.'.txt', $contents);
          $i++;
      }
  </code></pre>
  
  <p>UPDATE 2:
  I took zombats suggestion and modified the code to that below and it seems to work - </p>
  
  <pre><code>$i = 1;
      $fp = fopen("test.txt", "r");
      while(! feof($fp)) {
          $contents = fread($fp,20000);
          $contents .= stream_get_line($fp,1000,".");
          $contents .=".";
  
          file_put_contents("Split/".$tname."/"."new_file_".$i.".txt", $contents);
          $i++;
      }
  </code></pre>