PHP Tutorial Regular string external link code function
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 ("//i", $tempcontent, $tempurl);
$urls =array ();
foreach ($tempurl [0] as $value)
{
if (Strstr ($value, ' http '))
{
if (Stristr ($value, $localurl))
{
Continue
}
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;
}
Calling methods
$body = "AAA I am an external connection";
echo Getoutlink ($body);
http://www.bkjia.com/PHPjc/444911.html www.bkjia.com true http://www.bkjia.com/PHPjc/444911.html techarticle PHP Tutorial Regular string in the external link code function deleteemptyarray ($val) {$links = "", if (Is_array ($val)) {foreach ($val as $v =$_v {if (!empty ($_v[0])) {$ ...