TNET Weather Station Notebooks - PHP Weather FAQ's
Recently we added a new feature to our website which allows us to create Weather Facts. We can add to the facts as as needed and they are instantly available on the site in random order.
At the bottom of this page is a live example of the Weather Facts we are using
get-facts.php
<!-- Get Facts PHP Script -->
<?
$f_name = "./facts.txt";
$fp = fopen($f_name,"r");
$f_content= fread($fp, filesize($f_name));
fclose($fp);
$fnotes = explode(":::",$f_content);
shuffle($fnotes);
$i=0;
while(list(,$code) = each($fnotes)) {
$i++;
if ($i>=$max) {
break;
}
}
?>
<?=$code;?><br/> <br>/
Updated 8/19/2006
Sample Facts Data File
The fact file itself is a flat file with a delimiter at the end of each entry. The delimiter can be any unique set of characters, but we choose ::: which is basically never found in regular text. If you change the delimiter, you need to change the function above to match.
Sample Data File
<strong>RAIN FALL</strong><br/>In Arizona, typically, the heaviest rain falls during the summer thunderstorm season, or Monsoon, in our state. The rain can accumulate very quickly, resulting in flooded streets or washes, and can even cause deaths via flash flooding. In Phoenix, the greatest rainfall in a 24 hour period was 4.98 inches on July 1-2, 1911. This total is quite a bit less than the Arizona record of 11.4 inches, which fell on Workman Creek (near Globe) on September 4-5, 1970.::: <strong>COLD TEMPS</strong><br/>Hawley Lake recorded Arizona's coldest temperature of 40° below zero on January 7, 1971. The coldest temperature recorded in Phoenix was 16°, set on January 7, 1913. Phoenix Sky Harbor Airport, where the official temperature for Phoenix is recorded, rarely gets below freezing(32°F).:::
Note that you can include regular html code in the file and it will be used when displayed on the page. The delimiter is on the end of the text.
Adding the function to other pages
Below is the function we then call from each page we want to have a random weather fact section on
<p><?php include("get-facts.php"); ?></p>
You can then add what ever formatting you want to the above code to get the look and feel you want from the data.
Below is an actual sample of it in action.
Arizona Random Weather Facts
RAIN FALL
Terms such as "slight chance" of rain (10-20%), "chance" of rain (30-50%) or rain "likely" (60-70%) are used when there is uncertainty of receiving measurable precipitation anywhere in the forecast area (such as the Greater Phoenix Area). For instance, if there is only a 30-50 percent chance that rain will fall anywhere in the Phoenix Metro area, then the forecast will call for a "chance" of rain.


NEXRAD Radar & Satellite Maps




© 1992-2009 Copyright TNET Services, Inc.