Richard S. Crawford wrote:

> I am trying to get the title of an html file... you know, the string
> between the < title > and < /title > tags...
> 
> Here is the function I've got so far:
> 
> function fileTitle($fileName) {
>          $myFile = fopen($fileName, "r");
>          $myText="";
>          while (!feof($myFile)) {
>                  $myText .= fgets($myFile,255);
>          }
>          fclose($myFile);
>          if (eregi("<TITLE>(.+)</TITLE>",$myText,$theTitle)) return
> $theTitle[0];
>          else return "(No Title)";
> }

Try:
function getTitle($filename) {
   $fp = fopen($filename, "r");
    $filecontent = fread($fp, filesize($filename));
    if(eregi("<title>(.+)</title>", $content, $title_arr)) {
        return 
addslashes(htmlspecialchars(trim(strip_tags($title_arr[1]))));
    }
    else {
        return "(No Title)";
    }
}


Regards,
Johan

-- 
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