Nov
11
<?php
/**
* ページタイトルを取得する関数
*/
function getPageTitle( $url ) {
$html = file_get_contents($url); //(1)
$html = mb_convert_encoding($html, mb_internal_encoding(), "auto" ); //(2)
if ( preg_match( "/<title>(.*?)<\/title>/i", $html, $matches) ) { //(3)
return $matches[1];
} else {
return false;
}
}
?>
PHPでWEBページのタイトルを抜き出すサンプル [C!]