I have a code which will Display the log file data in the attached format, Here it will display all the readings in the table I need to display only the Latest or Last Reading how to display that?Please help me.I have attached the Log file in the link Log File
<meta http-equiv="refresh" content="10" >
<html>
<h1><center>Online Real Time Temperature and Pressure Monitoring System</center></h1>
<head>
<style>
table,th,td{
border:1px solid black;
border-collapse: collapse;
}
th,td{
padding: 5px;
}
</style>
</head>
<body>
<table align ="center" style="width:60%">
<tr>
<th>Year</th>
<th>Month</th>
<th>Date</th>
<th>Time</th>
<th>Sensor ID</th>
<th>Position</th>
<th>Pressure(psi)</th>
<th>Temperature</th>
</tr>
</body>
</html>
<?PHP
error_reporting(E_ALL & ~E_NOTICE);
$file_handle = fopen("D:/192.168.1.12_10000-gprs20160525.log", "rb");
while (!feof($file_handle) ) {
$line_of_text = fgets($file_handle);
$parts = explode(' ', $line_of_text);
$finalstr=$parts[0]."<BR>";
$hello=explode('>',end($parts));
$hello2=$hello[0]."<BR>";
$hello3=strlen($hello2);
if($hello3==23){
$timestamp=$hello2;
}
elseif($hello3==27)
{
$data=$hello2;
$hello4=explode('-',$timestamp."-".$data);
$year = substr($hello4[0],1,4);
$Month = substr($hello4[0],5,2);
$Date = substr($hello4[0],7,2);
$Hour = substr($hello4[0],9,2);
$Min = substr($hello4[0],11,2);
$sec = substr($hello4[0],13,2);
$time= $Hour.":".$Min.":".$sec;
$sensorid1=substr($hello4[1],4,2);
$sensorid2=substr($hello4[1],7,2);
$Pressure1=substr($hello4[1],10,2);
$Pressure2=substr($hello4[1],13,2);
$temperature=substr($hello4[1],16,2);
$finalsensor=$sensorid1.$sensorid2;
$finalPressure=$Pressure1.$Pressure2;
$finalPressure1=(hexdec($finalPressure)-1531)/100+0.61;
$finaltemperature1=hexdec($temperature)-40;
$position="FL";
?>
<html>
<head>
</head>
<body>
<tr>
<td><center><?php echo ($year);?></center></td>
<td><center><?php echo ($Month); ?></center></td>
<td><center><?php echo ($Date); ?></center></td>
<td><center><?php echo ($time); ?></center></td>
<td><center><?php echo ($finalsensor); ?></center></td>
<td><center><?php echo ($position); ?></center></td>
<td><center><?php echo ($finalPressure1); ?></center></td>
<td><center><?php echo ($finaltemperature1); ?></center></td>
</tr>
</body>
</html>
<?php
}
elseif($hello3==50)
{
echo "";
}
}
fclose($file_handle);
?>