We can evaluate the average temperature of the year , month or week in Php script. All we have to do is to collect all the temperatures of the month for example. After that we can calculate the average temperature that we have for the month.
First we will show the temperatures of every day recorded in the month of Feb. And then we will showing the AVG temperature recorded in the month. You can see the formula to get the AVG from this link click here. We all just need to make a php script like I’ve written below.
Code Sample For Average Temperature
<center> <span> <b>MONTH FEB </b> </span> </center> <?php $new= array( 78, 60, 62, 68, 71, 68, 73, 85, 66, 64, 76, 63, 75, 76, 73, 68, 62, 73, 72, 65, 74, 62, 62, 65, 64, 68, 73, 75, 79, 73); $avg=0; $result=0; ?> <center> <?php foreach($new as $key=> $value) { $result+=$value; echo "Feb ", ++$avg, " = ", $value, "°c<br>"; } ?> </center> <?php echo "<br><center>THE AVG TEMPERATURE OF FEB MONTH IS ", "'",$result/$avg, "°c'","<br>"; for($length=0;isset($new[$length]);$length++); for($i=0;$i<$length;$i++) { for($j=0;$j<$length;$j++) { if($new[$i]<$new[$j]) { $temp=$new[$i]; $new[$i]= $new[$j]; $new[$j]=$temp; } } } ?>