Tuesday, 5 January 2010

There's geeky ...

... and then there's this.

3 comments:

opsimath said...

I'm a bit of a Linux nut myself, but this - too much, even for me!

Thanks all the same, the other info on prompts was useful.

David Gillies said...

Bit verbose. I turned it into a function that takes a URL and fills an array:

function get_weather($url,&$warr)
{
$warr=array(); if(($wdata=file_get_contents($url))!==false){
$wtags=array("Temperature", "Wind Speed", "Humidity", "Rain Today");
foreach($wtags as $k){
if(($spos=stripos($wdata,$k.":"))!==false)
$warr[$k]=preg_replace("([^0-9.])", "", strip_tags(html_entity_decode(htmlspecialchars_decode(substr($wdata,$spos+strlen($k),30)))));
}
}
return(!empty($warr));
}

Simples!

Anonymous said...

There Ain't Half Been Some Clever Bastards.
John Gibson