All pastes #769182 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-11-11 05:48 UTC
rendered paste body
<?php
function Weather($loc1, $loc2) {
$t = file_get_contents("http://mobile.wunderground.com/cgi-bin/findweather/getForecast?brand=mobile&query=".$loc1."%2C+".$loc2);
preg_match("/\<b\>(.*?), (.*?)\<\/b\>\n/",$t,$loc);
preg_match("/\<span class=\"nowrap\"\>\<b\>(.*?)\<\/b\>&#176\;C\<\/span\>/",$t,$temp );
 preg_match("/\<tr\>\<td\>Humidity\<\/td\>\n\<td\>\<b\>(.*?)\<\/b\>\<\/td\>\<\/tr\>/",$t,$hum); 
preg_match("/\<span class=\"nowrap\"\>\<b\>(.*?)\<\/b\>&nbsp;km\/h\<\/span\>/",$t,$wind);
preg_match_all("/\<td align=\"right\"\>\<img src=(.*?)\<\/td\>\n  \<td align=\"left\"\>\<b\>(.*?)\<\/b\>\<br \/\>\n  (.*?).\n		(.*?)\n  (.*?)&deg; F.\n  \/\n  (.*?)&deg; C./",$t,$nday);
return "Weather for $loc[1] in $loc[2] Temperature: $temp[1]"."C - Humidity: $hum[1] - Wind: $wind[1]"."KM/h\n[".$nday[2][0]." - ".$nday[6][0]."C - ".$nday[3][0]."] [".$nday[2][1]." - ".$nday[6][1]."C - ".$nday[3][1]."] [".$nday[2][2]." - ".$nday[6][2]."C - ".$nday[3][2]."] [".$nday[2][3]." - ".$nday[6][3]."C - ".$nday[3][3]."] [".$nday[2][4]." - ".$nday[6][4]."C - ".$nday[3][4]."] [".$nday[2][5]." - ".$nday[6][5]."C - ".$nday[3][5]."] [".$nday[2][6]." - ".$nday[6][6]."C - ".$nday[3][6]."]";
}