Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Cumulus MX V4 beta test release 4.0.0 (build 4019) - 03 April 2024

Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

Cumulus PHP Functions

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderator: daj

Post Reply
TNETWeather

Cumulus PHP Functions

Post by TNETWeather »

.
Function to Output Humidex "Description"

The following PHP code provides a function that outputs the "description" of the humidex value. It uses the array to provide the lookup for what needs to be compared.

Code: Select all

$SITE['humidexval'] = array(
    "0" => array("0","29","Little or no discomfort"),
    "1" => array("30","34","Noticeable discomfort"),
    "2" => array("35","39","Evident discomfort"),
    "3" => array("40","44","Intense discomfort; avoid exertion"),
    "4" => array("45","0", "Dangerous discomfort"),
    "5" => array("54","0", "Heat stroke probable") );

echo humidexDesc ($humidex) . "<br/>";

// Function returns the description that matches the
// Humidex value.  Note that humidex is rounded to
// provide an int value.
    
function humidexDesc($invalue) {
    global $SITE;
    
    $compare = round($invalue);
    $desc = "";
    
    foreach( $SITE['humidexval'] as $key => $value) {
        if ( $value[0] == 0 && $compare <= $value[1] ) {
            $desc = $value[2];
        }
        if ( $value[1] == 0 && $compare >= $value[0] ) {
            $desc = $value[2];
        }
        if ( ($value[0] != 0 && $value[1] != 0 ) && 
            ($compare >= $value[0] && $compare <= $value[1]) ) {
            $desc = $value[2];
        }
    }
    return ($desc);
}
If the code is called with a Humidex of 36 it will return the description of "Evident discomfort".
Post Reply