How do I get an html page into a variable?
For example, if I am looking to get a page at an address (http://www.foo.com/), and perhaps I just want to pull the cost of purchasing foobars and display it on my site, is there a way to do this? Once I get the page in a variable I can figure out the rest.
-Chris
Use the file function and then you can pull out content line by line:
$fcontents = file ($filename);
while (list ($line_num, $line) = each ($fcontents)) { echo "<b>Line $line_num:</b> " . htmlspecialchars ($line) . "<br>\n"; }
a more comfortable way that I often use: $data = file("http://bla.bla.com/");
and, if you don't want $data to be an array containing one line per element:
$alldata = implode("", $data); now it's in one string.
see implode() doc for details on this.