首页 > php开发 > php 正则表达式获取网页所有网址和链接文字

php 正则表达式获取网页所有网址和链接文字

$url ='http://www.phprm.com';
$body=@file_get_contents($url);
preg_match_all('/href=['"]?([^'"]*)['"]?>(.*)/i',$body,$b);
$nums = array();
foreach($b[1] as $u){
  if(in_array($u,$nums)){
  continue;
  }
  $nums[]=$u;
  $title=strip_tags($u);
  echo $title."</br>";
}



本文地址:http://www.phprm.com/develop/797d3a3cef3043212ec5adc47087b28f.html

转载随意,但请附上文章地址:-)

标签:none

发表留言