Skip to main content.
^^

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

HUMIDEX
Definition Humidex - Over the years, several measures have been proposed to relate various combinations of temperature and humidity into a single number to approximate what hot, humid weather feels like to the average person. Of these, humidex is the one most familiar to Canadians. Humidex was introduced into Canada in 1965. The index is a summer analogue of the wind chill factor in that it is an equivalent air temperature. Air of a given temperature and humidity is equated in comfort to air of a higher temperature that has a negligible moisture content. Comfort is quite subjective and largely dependent on the age and health of the individual. Weather conditions causing prickly heat in an infant may result in heat cramps in a teenager, heat exhaustion in a middle-aged and heat stroke in a senior. Humidex is also limited as an overall hot-weather comfort index because it does not consider other factors such as pressure, wind speed, precipitation, sunshine or pollen.

  Goto Top Of Page
Web Design by TNET   © 1992-2010 Copyright TNET Services, Inc.
Home | Privacy Statement | Site Map | About Us - TNETWebGen v2.6.1
Some images and designs (SM) TNET Services, Inc.
SWN Member