fopen // eregi question
| From: | Brian V Bonini | Date: | Wed, 26 Sep 2001 14:21:03 +0000 |
| Subject: | fopen // eregi question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-68861@lists.php.net to get a copy of this message | ||
From the PHP manual:
http://www.php.net/manual/en/features.remote-files.php
Example 20-1. Getting the title of a remote page
<?php
$file = fopen ("http://www.php.net/",
"r");
if (!$file) {
echo "<p>Unable to open remote file.\n";
exit;
}
while (!feof ($file)) {
$line = fgets ($file, 1024);
/* This only works if the title and its tags are on one line */
if (eregi ("<title>(.*)</title>", $line, $out)) {
$title = $out[1];
break;
}
}
fclose($file);
?>
How would you make this work if the tags and content
spanned several lines?