Storing Text from Webpage as Variable

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
NorthPilot06
Forum Newbie
Posts: 3
Joined: Sun Oct 02, 2005 4:20 pm

Storing Text from Webpage as Variable

Post 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:
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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");
Post Reply