If you use preg_match (PERL style Regex) instead of ereg
you can use the s match modifier which tells it to treat the
entire file as a single line... so your Regex would be

if (preg_match("|<title>(.*)</title>|is", $line, $out)) {

(The i is case insensitive... since you were using eregi)

Hope that helps

Sheridan Saint-Michel
Website Administrator
FoxJet, an ITW Company
www.foxjet.com


----- Original Message ----- 
From: "Brian V Bonini" <[EMAIL PROTECTED]>
To: "PHP Lists" <[EMAIL PROTECTED]>
Sent: Wednesday, September 26, 2001 9:21 AM
Subject: [PHP] fopen // eregi question


> >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?
> 
>     
>  
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to