pregp html title tag
Hi all,
I have a problem with a script, I'm trying to read an html file in and grep
the title out of it with this code:
preg_match("/<title>(.*)<\/title>/i", $html_text, $title);
$output = $output . "<li><a href=" . $filename . ">" . $title[1] .
"</a><br />";
Now, the flat HTML pages I am greping are generate from an ASP script (don't
ask) and if I just copy the created html pages and pop them in with my PHP
script then the script doesn't pick out the title.
If however, before uploading to the directory my PHP script is in, I open
the HTML file in DreamWeaver then save it again without modification, then
pop it in the directory, the PHP file CAN grep the title tag.
I'm at a loss why it works if I open and save, but not if i just directly
upload the page.
Something to do with MSDOS/Windows encoding or something maybe??? If so how
would I alter my pgrep to cater for different text formats??
I'm not sure that is the case though as it doesn't matter if my </title> is
at the end of a line or not, still doesn't work unless i open and save with
DreamWeaver.
Anthony.
|