1. 程式人生 > >PHP正則表達式提取html超鏈接中的href地址

PHP正則表達式提取html超鏈接中的href地址

spa match 正則表達式 arr pan 正則表達 reg code div

$preg=/<a .*?href="(.*?)".*?>/is;
 preg_match_all($preg,$str,$array2); 
for($i=0;$i<count($array2[1]);$i++)//逐個輸出超鏈接地址

{

  echo $array2[1][$i]."<br />";

}

PHP正則表達式提取html超鏈接中的href地址