title: preg_match_all with multiple lines
body: <p>I'm creating a script that finds all the error_log files on my server. Here's a sample of a typical error_log file:</p>
  
  <pre><code>[08-Feb-2012 05:45:56] PHP Fatal error: Uncaught exception 'Swift_RfcComplianceException' with message 'Address in mailbox given [] does not comply with RFC 2822, 3.6.2.' in /lib/SwiftMailer/classes/Swift/Mime/Headers/MailboxHeader.php:308
  Stack trace:
  #0 /lib/SwiftMailer/classes/Swift/Mime/Headers/MailboxHeader.php(238): Swift_Mime_Headers_MailboxHeader-&gt;_assertValidAddress('')
  #1 /lib/SwiftMailer/classes/Swift/Mime/Headers/MailboxHeader.php(96): Swift_Mime_Headers_MailboxHeader-&gt;normalizeMailboxes(Array)
  #2 /lib/SwiftMailer/classes/Swift/Mime/Headers/MailboxHeader.php(60): Swift_Mime_Headers_MailboxHeader-&gt;setNameAddresses(Array)
  [08-Feb-2012 05:46:18] PHP Fatal error: Uncaught exception 'Swift_RfcComplianceException' with message 'Address in mailbox given [] does not comply with RFC 2822, 3.6.2.' in /lib/SwiftMailer/classes/Swift/Mime/Headers/MailboxHeader.php:308
  Stack trace:
  #0 /lib/SwiftMailer/classes/Swift/Mime/Headers/MailboxHeader.php(238): Swift_Mime_Headers_MailboxHeader-&gt;_assertValidAddress('')
  #1 /lib/SwiftMailer/classes/Swift/Mime/Headers/MailboxHeader.php(96): Swift_Mime_Headers_MailboxHeader-&gt;normalizeMailboxes(Array)
  #2 /lib/SwiftMailer/classes/Swift/Mime/Headers/MailboxHeader.php(60): Swift_Mime_Headers_MailboxHeader-&gt;setNameAddresses(Array)
  [15-Feb-2012 15:39:10] PHP Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting ']' in /settings.php on line 47
  </code></pre>
  
  <p>I've used the following code to extract each error individually so I can display them for easy viewing</p>
  
  <pre><code>preg_match_all('/\[\d{2}-\w{3}-\d{4} \d{2}:\d{2}:\d{2}\].*/', $error_log_file, $error_log_parts);
  </code></pre>
  
  <p>It worked but the problem was it wasn't selecting multiple lines. </p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
      (
          [0] =&gt; [08-Feb-2012 05:45:56] PHP Fatal error:  Uncaught exception 'Swift_RfcComplianceException' with message 'Address in mailbox given [] does not comply with RFC 2822, 3.6.2.' in /home/elvanto/public_html/lib/SwiftMailer/classes/Swift/Mime/Headers/MailboxHeader.php:308
          [1] =&gt; [08-Feb-2012 05:46:18] PHP Fatal error:  Uncaught exception 'Swift_RfcComplianceException' with message 'Address in mailbox given [] does not comply with RFC 2822, 3.6.2.' in /home/elvanto/public_html/lib/SwiftMailer/classes/Swift/Mime/Headers/MailboxHeader.php:308
          [2] =&gt; [15-Feb-2012 15:39:10] PHP Parse error:  syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting ']' in /home/elvanto/public_html/roster-settings.php on line 47
      )
  
  )
  </code></pre>
  
  <p>So I added an 's' to the end:</p>
  
  <pre><code>preg_match_all('/\[\d{2}-\w{3}-\d{4} \d{2}:\d{2}:\d{2}\].*/s', $error_log_file, $error_log_parts);
  </code></pre>
  
  <p>But now it seems to select everything. I need a way to select everything until it comes to a new date. E.g: [08-Feb-2012 05:46:18]</p>
  
  <p>What code would I need to add to do this?</p>