01: <?php
02: //----------------------------------------------------------------------
03: //  get-stove-temp.php
04: //----------------------------------------------------------------------
05: 
06: // $txt_file = file_get_contents("/home/gorhas/public_html/d3/stoved.log");
07: 
08: $file = fopen("/home/gorhas/public_html/framework/stoved.log", "r");
09: 
10: // $rows = explode("\n", $txt_file);
11: 
12: // array_shift($rows);
13: 
14: $time_data = array();
15: 
16: while(!feof($file))
17: {
18: 
19: //foreach($rows as $row => $data)
20: //{
21: 
22:     $line = fgets($file);
23: 
24:     //get row data
25:     $row_data = explode(' ', $line);
26: 
27:     //$info[$row]['id']           = $row_data[0];
28:     //$info[$row]['name']         = $row_data[1];
29:     //$info[$row]['description']  = $row_data[2];
30:     //$info[$row]['images']       = $row_data[3];
31: 
32:     if($row_data[0] == '2016-01-15' && $row_data[2] == 'EE000000512FB128')
33:     {
34: 
35:         $values = array("time" => $row_data[0] . " " . $row_data[1],
36:                         "temp"=> $row_data[3]);
37:         
38: 
39:         array_push($time_data, $values); 
40: 
41:         //display data
42:         //echo ' Date: ' . $row_data[0] . '<br />';
43:         //echo ' Time: ' . $row_data[1] . '<br />';
44:         //echo ' Id: ' . $row_data[2] . '<br />';
45:         //echo ' Temp: ' . $row_data[3] . '<br />';
46: 
47:         //printf("\n");
48: 
49:         //echo '<br />\r\n';
50: 
51:     }
52: 
53: }
54: 
55: echo json_encode($time_data);
56: //----------------------------------------------------------------------
57: //
58: //----------------------------------------------------------------------
59: ?>
60: 
61: