程序代码

  1. function match_links($document) {    
  2.     preg_match_all("'<s*as.*?hrefs*=s*(["'])?(?(1)(.*?)1|([^s>]+))[^>]*>?(.*?)</a>'isx",$document,$links);                        
  3.     while(list($key,$val) = each($links[2])) { 
  4.         if(!emptyempty($val)) 
  5.             $match['link'][] = $val; 
  6.     } 
  7.     while(list($key,$val) = each($links[3])) { 
  8.         if(!emptyempty($val)) 
  9.             $match['link'][] = $val; 
  10.     }        
  11.     while(list($key,$val) = each($links[4])) { 
  12.         if(!emptyempty($val)) 
  13.             $match['content'][] = $val; 
  14.     } 
  15.     while(list($key,$val) = each($links[0])) { 
  16.         if(!emptyempty($val)) 
  17.             $match['all'][] = $val; 
  18.     }                
  19.     return $match; 
  20. }
    1. <?php  
    2. echo preg_replace("/(?<=href=)([^>]*)(?=>)/i","#", "<a href='www.phpfensi.com'>你好,点这里看看</a><a href='www.phpfensi.com'>你好,点这里看看</a>");  
    3. ?> 
posted @ 2021-08-18 09:35  v17166570219  阅读(454)  评论(0)    收藏  举报