title: Convert each row in a txt file into JSON with PHP
body: <p>So I got an application which generates a log like this:</p>
  
  <pre><code>INFO:root:14/09/2016 13:44:13: Temp: 16.0 C  Humidity: 95.0 % 
  
  INFO:root:14/09/2016 13:46:13: Temp: 25.0 C  Humidity: 78.0 % 
  
  INFO:root:14/09/2016 13:48:14: Temp: 25.0 C  Humidity: 78.0 % 
  </code></pre>
  
  <p>And I'm building a simple website which aims to show this log and be able to sort it. I'd thought I'd read the log file with the help of PHP which should convert it into a JSON Array so it's easier to handle for my Javascript. The only problem is that I can't seem to get it working. I have tried alot of example code, many from Stackoverflow but none of it seems to work. I'm kinda new to PHP to so I'm not sure what to do here.</p>
  
  <p>These are some things I've tried:</p>
  
  <pre><code>$logFile = file_get_contents( "../../../home/shares/flower_hum/humid.log" ); 
  //*Did not work
  $json = json_decode(file_get_contents($file), true);
  //*Did not work
  $lines = file($logFile, FILE_IGNORE_NEW_LINES)
  //*Did not work
  $fp = @fopen($filename, 'r'); 
  if ($fp) {
  $array = explode("\n", fread($fp, filesize($filename)));
  }
  </code></pre>
  
  <p>The format I want as JSON is something like this:</p>
  
  <pre><code>"log":[
  {"14/09/2016 13:54:21":"Temp: 26.0 C":"Humidity: 76.0 %"}, 
  {"14/09/2016 13:56:21":"Temp: 25.0 C", "Humidity: 75.0 %"} 
  ]
  </code></pre>