What I am doing is opening up the Yahoo! weather report for my location, which is a javascript document, then removing all the tables and stuff so I can just extract the temperature (and later the weather condition itself - eg. sunny or rainy etc etc) so i can then present it my own way.
The temperature is located between the $junk. (I will deal with the variable image at the end once i solve the first bit
Just not sure exactly where I've gone wrong. any help would be great.
Thanks!
Code: Select all
<?
$weather = file_get_contents("http://data.geo.yahoo.com/geo/v1?w=c,NZXX0003&hbc=ffffff&hfc=314584&hff=Verdana&hfs=2&ibc=FFFFFF&ifc=0000ff&iff=Verdana&ifs=1&udd=1&ufc=000000&uff=Verdana&ufs=2&ct=NZ&tz=UV&ts=996800400");
$junk = "document.write(''<table border=0 cellpadding=4 cellspacing=0 width="100%" bgcolor="ffffff"><tr><td colspan=3><a href="http://my.yahoo.com/my/p1/?http://weather.yahoo.com"><font color="314584" face="Arial" size="4"><b>Weather</b></font></a></td></tr><tr bgcolor="#ffffff"><td><a href=http://weather.yahoo.com/forecast/NZXX0003_c.html><font face="Times New Roman" size="3" color="#000000">Auckland</font></a><font color=#ff0000>*</font></td><td align=right><font face="Times New Roman" size="3" color="#000000">";
$junk2 = "</td><td align=right><font face="Times New Roman" size="3" color="#000000"><img height=24 width=32 src=http://us.i1.yimg.com/us.yimg.com/i/my/we/12.gif alt="Rain/Windy"></font></td></tr></table>'')";
$weather = str_replace(array($junk, $junk2), "", $weather);
echo $weather;
?>it works... as far as it wont die horribly, but it doesnt actually replace anything, just appears as per normal.