Click to See Complete Forum and Search --> : Php get title of page?
Pixel-Artist
01-13-2006, 09:40 PM
Someone asked me to make a bookmark system for psp for version without webbrowser due newer versions not working with homebrewed stuffs. It uses a cookie. I was just wondering if there is a way to get title of the page from the url?
NogDog
01-13-2006, 09:56 PM
Well, after reading your post a couple times, I still don't know what you're asking. :(
Pixel-Artist
01-13-2006, 09:58 PM
I basicly want to know if php can grad the title of a page.
NogDog
01-13-2006, 10:00 PM
Do you mean the text between the <title> and </title> tag of some page specified by its URL?
Pixel-Artist
01-13-2006, 10:08 PM
yes
NogDog
01-13-2006, 10:19 PM
function get_title($url)
// returns false if can't read file, "" if no title, else title string
{
$pageText = @file_get_contents($url);
if($pageText)
{
if(preg_match('/<title>(.+)<\/title>/i', $pageText, $match))
{
return($match[1]);
}
else
{
return("");
}
}
return(FALSE);
}