my non-programmer-brain reached the limit. I'm collecting the temperature-value of a sensor in a text file (raspberry pi with a bash-script), easy stuff:
23.2
24.5
12.8
6.8
27.9
and so on. I now try to read the file (PHP) to echo the highest and lowest temperatur in the list. I've found a simple solution in the www, which is based on this input/start:
$temperatures = array(78,60,62,1,68,73);
echo "5 lowest temperatures: ";
echo implode(", ", array_slice($temperatures, 0, 5));
echo "Average temperature: ";
echo number_format(array_sum($temperatures) / count($temperatures), 1);
..(and so on)..
What I now try to accomplish, is to read the file and insert the values into this array for $temperatures. But I don't understand the way from read in the file
line by line via explode
and then implode
with ,
so that I can use it for the output. I don't want to assign other values, there are no headers, no multi-arrays and whatever... I guess the solution is damn easy, but I just see only more arrays and millions of solutions to assign, combine, split and other stuff. Maybe it's too easy for you and to complicate for my world.
Any help would be nice - also, if you have a complete other or better idea for the target/result?
Thanks in advance & sorry for my bad english!