PHP Tutorial External link code function in regular string
function Deleteemptyarray ($val)
{
$links = ';
if (Is_array ($val))
{
foreach ($val as $v =>$_v)
{
if (!empty ($_v[0))
{
$links. =$_v[0]. ' | '
}
}
Return substr ($links, 0,-1);
}
Else
{
return false;
}
}
Function Getoutlink ($body)
{
$tempcontent = $body;
preg_match_all ("/<a (. *?) Href= (. *?) </a>/i ", $tempcontent, $tempurl);
$urls =array ();
foreach ($tempurl [0] as $value)
{
if (strstr ($value, ' http ')
{
if (Stristr ($value, $localurl))
{
re-enters
}
Else
{
preg_match_all ("/hrefs*=s*" ([' "]?) (.*?) 1/is ", $value, $vlink);
$urls [] = $vlink [2];
}
}
}
//print_r ($urls);
$strurl = explode (' | ', Deleteemptyarray ($urls));
$tempcount = Array_unique ($strurl);
echo ' outer chain '. COUNT ($tempcount)-1;
}
//Call method
$body = "<a href=/ab.htm>aaa</a><a href=http://www.jzread.com> I am an external connection </a>";
Echo Getoutlink ($body);