Re: Re: I suck at regular expressions!
| From: | Richard S. Crawford | Date: | Thu, 15 Nov 2001 08:01:51 +0000 |
| Subject: | Re: Re: I suck at regular expressions! | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-74681@lists.php.net to get a copy of this message | ||
Not quite. I have the same problem.
At 11:36 PM 11/14/2001, Johan Holst Nielsen wrote:
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) {Sliante, Richard S. Crawford http://www.mossroot.com mailto:rscrawford@mossroot.com AIM: Buffalo2K ICQ: 11646404 Y!: rscrawford "It is only with the heart that we see rightly; what is essential is invisible to the eye." --Antoine de Saint Exupéry "Push the button, Max!"$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)) { returnaddslashes(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: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net