Главная > PHP > preg_math title html — получить title страницы по URL

preg_math title html — получить title страницы по URL

function get_title($url){
	$fp=file_get_contents($url);
	if(!$fp){
		return false;
	}
	$res=preg_match("/<title>(.*)<\/title>/siU",$fp,$title_matches);
	if(!$res){
		return false;
	}
	$title=preg_replace('/\s+/',' ',$title_matches[1]);
	$title=trim($title);
	return $title;
}
Categories: PHP Tags:
  1. Пока что нет комментариев.
Похожие публикации