Several to get all the hyperlink address codes in an HTML string
$ss = "<a href= ' 1.gif ' >d</a>adfxx<a href=" dir.html ">dir</a>";
Print_r (Gethref ($SS));
function Gethref ($temp) {
Preg_match_all ('/<a.*: |t|r|n)? href=[' "]? +?) ['"]? (:(?: |t|r|n) +.*? > (. +?) </a.*?>/sim ', $temp, $a);
return $a [1];
}
All a connections below
$htm = Preg_replace ("@<a" (. *?) </a> @is "," $ ", $ss);
Print_r ($htm);
Compare full extract URL connection address
$url = "http://www.jzread.com";
$html =file_get_contents ($url, "R");
Preg_match_all ("/(<a) (. *) (href=) ([^>]*) (>) ([^<]*] (<) ([^>]*) (>)/", $html, $matches);
For ($i =0 $i <count ($matches [0]); $i + +)
{
echo "| | |" $matches [2][$i]. $matches [3][$i]. $matches [4][$i]. "| |" $matches [6][$i]. $matches [8][$i]. " <br> ";
}//extract all linked addresses in the article string
Preg_match_all ('/(? <=href= ') [wd.:/] * *, $STR, $FSTR);