I'm trying to remote contents from a particular website using bpat1434's guide found here. I can't seem to make it work. Can someone help me with how to do this?
Here is the html when I view the code, what I need is the 'KLGA'.
<tr>
<th class="secondaryHeader">Destination</th>
<td class="smallrow1" nowrap="nowrap" colspan="2" style="text-align: left"> <span title="New York, NY">LaGuardia</span> [<a href="/live/airport/KLGA">KLGA</a>]</td>
</tr>
Here is the code from bpat1434's updated code:
<?php
$url = "http://www.weather.com/weather/local/21250";
$handle = fopen($url, "r");
$contents = file_get_contents($url);
fclose($handle);
$temp_pattern = "@<B CLASS=obsTempTextA>([0-9]*)°F</B><BR><B CLASS=obsTextA>Feels Like<BR> ([0-9]*)°F</B>@";
$loc_pattern = "@<H2 CLASS=\"moduleTitleBar\">[\s\n]*<B>Right Now for<\/B><BR>[\s\n]*([a-zA-Z0-9,\(\)\s]*)<BR>@";
// preg_match(pattern, string, returned array)
preg_match($temp_pattern, $contents, $temps);
preg_match($loc_pattern, $contents, $location);
echo 'Currently in '.$location[1].':<br>
the temperature is <b>'.$temps[1].'</b>°F.<br>
It feels like <i>'.$temps[2].'</i>°F.';
?>