php 正则表达式获取网页所有网址和链接文字
栏目:php教程时间:2014-06-06 12:50:49
- $url ='http://www.phpfensi.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>";
- }
------分隔线----------------------------
------分隔线----------------------------