The Most Active and Friendliest
Affiliate Marketing Community Online!

“AdsEmpire”/  Direct Affiliate

PHP function - Get webpage title providing a link

arthur.online

New Member
affiliate
Another function from PHP information



Get webpage title providing a link



function getdoctitle($link) {
$lines = @file($link);
$str=implode(”\n”,$lines);
$str=str_replace(”Title>”,”title>”,$str);
$str=str_replace(”TItle>”,”title>”,$str);
$str=str_replace(”TITle>”,”title>”,$str);
$str=str_replace(”TITLe>”,”title>”,$str);
$str=str_replace(”TITLE>”,”title>”,$str);
if (strpos(” $str”,”<title>”) and strpos(” $str”,”</title>”)) {
$a1=explode(”<title>”,$str);
$str2=$a1[1];
$a2=explode(”</title>”,$str2);
$str3=$a2[0];
return $str3;
} else {
return “”;
}
}
 
You could replace all "str_replace" calls with a preg_match function like:

Code:
preg_match('/<title>([^>]*)<\/title>/si', $str, $matches );
 
MI
Back