Calculate Highest And Lowest Temperatures In Php

Right now we are going to have the highest and lowest temperature rates recorded in the whole month. Off course we need to have all these temperatures to get the lowest and highest temperatures. It’s quite simple i’m going to write the php code script to do this task. All you need to do is to copy my code and run on your system and then customize it according to your needs.

Code

Highest/Lowest Temperates

<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);
$average=0;
$result=0;
?>
<center>
  <?php
foreach($new as $key=> $value)
{
$result+=$value;
echo "Feb ", ++$average, " = ", $value, "&degc<br>";
}
?>
</center>
<?php
/* echo "<br><center>THE AVERAGE TEMPERATURE OF FEB MONTH IS ", "'",$result/$average, "&degc'","<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;
}
}
}

echo "<center>Seven highest Temperatures Of MONTH FEB are : ";
$length--;	

for($i=$length;$i>=$length-6;$i--)
{
	echo $new[$i], "&degc\t,";	
}
echo "<br>";

echo "Seven Lowest Temperatures Of MONTH FEB are : ";	
for($i=0;$i<7;$i++)
{
	echo $new[$i], "&degc\t,";	
}

?>

Result

highest lowest

highest lowest