Re: How to use Remote Files in PHP?
You can follow the following example to open a file on a remote web server, analyzing the results to extract the information you need, and then use it in an application database, or simply edit the information in the style of your site. The following example provided by me is for getting the title of a remote page :
PHP Code:
<?php
$file = fopen ("http://www.demo.com/", "r");
if (!$file) {
echo "<p>Unable to open remote file.\n";
exit;
}
while (!feof ($file)) {
$line = fgets ($file, 1024);
if (preg_match ("@\<title\>(.*)\</title\>@i", $line, $out)) {
$title = $out[1];
break;
}
}
fclose($file);
?>
I do to dead flowers what people at morgues do to dead people. Suck all the moisture out, dip them in plastic, paint them up pretty and put them in a nice frame.
Bookmarks