URLからタイトルをぶっこ抜く
このサイトに参照したコードがある:
http://www.dreamincode.net/code/snippet3108.htm
しかし、これだと
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");
$len = strpos($str2, "</title>")+8 - $start;
$title=substr($str, $start, $len);
$title = strip_tags($title,'<b><strong>');
$encoding= mb_detect_encoding($title);
$title=mb_convert_encoding($title, 'utf-8', 'auto');
return $title;//substr($str, $start, $len);
}