getTemp()); } $buff[] = $vals; $last = $vals; if (count($buff)>BUFFER_SIZE) { array_shift($buff); } $buffs = count($buff); foreach($vals as $i=>$vcur) { $avg = array_sum(array_column($buff, $i))/$buffs; $vals[$i] = sprintf("%.1f", $avg); } $vals = array_merge($last, $vals); array_unshift($vals, $c++); fputcsv(STDOUT, $vals, ';'); sleep(5); }