Page 1 of 1

Storing Text from Webpage as Variable

Posted: Mon Oct 03, 2005 10:01 pm
by NorthPilot06
Hey guys,

I have this site that extracts the information off of a remote site:

Code: Select all

<?php
    $lines = implode("", file("http://www.weather.com/outlook/recreation/ski/local/43147?lswe=43147&lwsa=Weather36HourSkiCommand&from=whatwhere"));
    echo $lines;
?>
As you can see, the page that loads (http://www.ski-us.com/test1.php) has most of the data that the actual website has...Anyways, you should see a 62 F somewhat near the middle of the screen depending on your resolution - How would I go about extracting that number (62 or whatever number is in its place; the site updates automatically) and storing it in a variable, lets call it $temperature.

Thanks in advance! :wink:

Posted: Mon Oct 03, 2005 10:21 pm
by feyd
as with most extractions, regex is probably the best bet.

I could have swore I posted the following earlier, but I guess not:

Code: Select all

implode("",file("something"));
is better written

Code: Select all

file_get_contents("something");