ページのURLからそのページのタイトルを取得する
urlから、そのページのtitleを取得する方法
ソース: http://www.dreamincode.net/code/snippet3108.htm
これだとエラーが出ることがあったり、encodingによって文字化けするので、ちょっと改良
function getTitle($url) { $fh = @fopen($url, "r"); $str = @fread($fh, 7500); // read the first 7500 characters, it's gonna be near the top @fclose($fh); $str2 = strtolower($str); $start = strpos($str2, "<title>")+7; $len = strpos($str2, "</title>") - $start; $title=substr($str, $start, $len); $encoding= mb_detect_encoding($title); $title=mb_convert_encoding($title, mb_internal_encoding(), $encoding); return $title;//substr($str, $start, $len); }