A constant reminder that life was so much better before the internet
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.
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!
There Ain't Half Been Some Clever Bastards.John Gibson
Post a Comment
3 comments:
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.
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!
There Ain't Half Been Some Clever Bastards.
John Gibson
Post a Comment