Hi,
I want to fetch data from a text file with 2 col. and then to get once the MAX() and MIN() data out.
file.txt content:
2007-07-22 22:00|25,4
2007-07-22 22:05|29,0
2007-07-22 22:10|25,4
2007-07-22 22:15|20,8
2007-07-22 22:20|23,4
the output is once "23,4" and for the MAX it should be 29,0.
One part of the code works, but not the other one. I get get the MIN and MAX. I don't understand what wrong?. Could someone help me please?
$fp = fopen("c:\\test\\file.txt", "r");
$last_line = count(file("c:\\test\\file.txt"));
if($fp>=1)
{
$i=0;
while(feof($fp)==0)
{
$i++;
$servertemp=chop(fgets($fp,256));
if($i == $last_line)
{
if(!empty($servertemp))
{
$the_last_entry = $servertemp;
$explode_last_entry = explode("|",$servertemp);
}
}
$get_max = max($explode_last_entry[1]);
$get_min = min($explode_last_entry[1]);
}
}
fclose($fp);
echo "Date & Time: $explode_last_entry[0]"; //this works
echo "Temperature: $explode_last_entry[1]"; //this works
echo "Max. Temp. : $get_max"; //this doesn't work
echo "Max. Temp. : $get_min"; //this doesn't work