Skip to content

Instantly share code, notes, and snippets.

@bmcculley
Created February 18, 2014 08:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bmcculley/9067069 to your computer and use it in GitHub Desktop.
Save bmcculley/9067069 to your computer and use it in GitHub Desktop.
Find the heat index temperature in PHP.
<?php
/*
* The heat index formula in PHP
* https://en.wikipedia.org/wiki/Heat_index#Formula
*/
function hi($T,$rh) {
$c1 = -42.379;
$c2 = 2.04901523;
$c3 = 10.14333127;
$c4 = -0.22475541;
$c5 = -6.83783 * pow(10, -3);
$c6 = -5.481717 * pow(10, -2);
$c7 = 1.22874 * pow(10, -3);
$c8 = 8.5282 * pow(10, -4);
$c9 = -1.99 * pow(10, -6);
$hi = $c1 + $c2*$T + $c3*$rh + $c4*$T*$rh + $c5*$T*$T + $c6*$rh*$rh + $c7*$T*$T*$rh + $c8*$T*$rh*$rh + $c9*$T*$T*$rh*$rh;
return round($hi);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment