title: php function to split an array at each blank line?
body: <p>I'm building a script which will open a saved text file, export the contents to an array and then dump the contents in a database. So far I've been able to get the file upload working quite happily and can also open said file.</p>
  
  <p>The trouble I'm having is the contents of the file are variable, they have a fixed structure but the contents will change every time. The structure of the file is that each "section" is seperated by a blank line.</p>
  
  <p>I've used php's file() to get an array ... I'm not sure if there's a way to then split that array up every time it comes across a blank line?</p>
  
  <pre><code>  $file = $target_path;
    $data = file($file) or die('Could not read file!');
  </code></pre>
  
  <p>Example output:</p>
  
  <pre><code>[0] =&gt; domain.com
  [1] =&gt;  # Files to be checked
  [2] =&gt;   /www/06.php
  [3] =&gt;   /www/08.php
  [4] =&gt; 
  [5] =&gt; domain2.com
  [6] =&gt;  # Files to be checked
  [7] =&gt;   /cgi-bin/cache.txt
  [8] =&gt;   /cgi-bin/log.txt
  [9] =&gt; 
  [10] =&gt; domain3.com
  [11] =&gt;  # Files to be checked
  [12] =&gt;   /www/Content.js
  [13] =&gt; 
  </code></pre>
  
  <p>I know that Field 0 and 1 will be constants, they will always be a domain name then that hash line. The lines thereafter could be anywhere between 1 line and 1000 lines.</p>
  
  <p>I've looked at array_chunk() which is close to what I want but it works on a numerical value, what would be good if there was something which would work on a specified value (like a new line, or a comma or something of that sort!).</p>
  
  <p>Lastly, apologies if this has been answered previously. I've searched the usual places a few times for potential solutions. </p>
  
  <p>Hope you can help :)
  Foxed</p>