Jump to content

Get Title Tag


The Little Guy

Recommended Posts

I am trying to get the title tag from a html string.

 

I have this:

if(preg_match("~\<title.+?\>(.+?)\</title\>~i", $this->info, $matches)){
return $matches[1];
}

 

but it only works on sites where the title looks something like this <title id="something">Title Here</title> but when it looks like this: <title>Title Here</title> it doesn't work.

 

What can I do?

Link to comment
https://forums.phpfreaks.com/topic/193397-get-title-tag/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.