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
Moon Phase Misconception...
"The most common incorrect reason given for the cause of the Moon's phases is that we are seeing the shadow of the Earth on the Moon! But this cannot be correct: when the Moon passes through the shadow of the Earth, we get a lunar eclipse. Anyone who has seen a lunar eclipse, though, might remember that the Moon actually passes through the Earth's shadow only rarely, so that can't be why the Moon has phases. The real reason for the Moon's phases depends on two things: the Moon is round, and the angle it makes with the Earth and Sun changes over its orbit."
- As Quoted From Bad Astronomy


NEXRAD Radar & Satellite Maps




© 1992-2010 Copyright TNET Services, Inc.