// Get the webpage into a string
$html = join ("", file ("http://www.altavista.com"));

// Using eregi
eregi("<title>(.*)</title>", $html, $tag_contents);

// Using preg_match (faster than eregi)
// The i in the end means that it is a case insensitive match
preg_match("/<title>(.*)<\/title>/i", $html, $tag_contents);

$title = $tag_contents[1];

// Tobias

"Chris Empson" <[EMAIL PROTECTED]> wrote in message
9b6vkl$jpf$[EMAIL PROTECTED]">news:9b6vkl$jpf$[EMAIL PROTECTED]...
> Could anyone tell me how to extract a string from between a pair of HTML
> tags?
>
> Specifically, I would like to extract the page title from between the
> <title> and </title> tags. I have read the regular expression docs and I'm
> still a bit stuck.
>
> Can anyone help?
>
> Thanks in advance,
>
> Chris Empson
>
> [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]
>



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