title: Sort log messages
body: <p>Hello everyone I'm trying to sort my log messages from files.
  My log file looks like this
  <a href="http://kopy.io/tA8bv" rel="nofollow">http://kopy.io/tA8bv</a> 
  I want to achive something like this </p>
  
  <pre><code>['debug'] =&gt; [
      ['logs'] =&gt; [
          ['log message'] =&gt; [
              '2016-04-10',
              '2016-04-10',
              '2016-04-10'
          ],
          ['log message'] =&gt; [
              '2016-04-10',
              '2016-04-10',
              '2016-04-10'
          ],
          ...
      ]
  ],
  ['Crit'] =&gt; [
      ['logs'] =&gt; [
          ['log message'] =&gt; [
              '2016-04-10',
              '2016-04-10',
              '2016-04-10'
          ],
          ['log message'] =&gt; [
              '2016-04-10',
              '2016-04-10',
              '2016-04-10'
          ],
          ...
      ]
  ]
  </code></pre>
  
  <p>Here is my code but it doesnt work correctly it ommits some lines </p>
  
  <pre><code>$file = fopen(self::DIRECTORY.$filename, 'rb');
  while(($line = fgets($file)) !== false) {
      if($this-&gt;lineHasDate($line)) {
          $logDate = $this-&gt;getLogDate($line);
          $logType = $this-&gt;getTypeOfLog($line);
          $content .= $line;
          // $content ='';
      }
      while(!$this-&gt;lineHasDate($line) &amp;&amp; ($line = fgets($file)) !== false) {
          // echo $line;
          $content .= $line;
      }
      $this-&gt;logs[$logType]['logs'][] = $content;
      $content = '';
  }
  fclose($file);
  </code></pre>