《PHP編程:php批量刪除超鏈接的實現方法》要點:
本文介紹了PHP編程:php批量刪除超鏈接的實現方法,希望對您有用。如果有疑問,可以聯系我們。
PHP應用清除掉一段html文本內容中的超鏈接最常見的寫法可以如下:
PHP應用
$find="this string is my find";
$string='<font color="red">這段內容將要被替換掉</font>';//將超鏈接替換成的內容
echo ereg_replace('<a([^>]*)>([^<]*'.$find.'[^>]*)</a>','<font color="red">\\2</font>',$content);
PHP應用下面同時分享幾種獲取html文本內容中的超鏈接的文本內容辦法:
PHP應用
//辦法一
preg_match_all('/<(a|a)[s]{0,1}[w=":()]*>[nrn]*(check user)[nrn]*</(a|a)>/i',$string,$matches);
//辦法二
preg_match_all('/<a[dd]*>check user</a>/i',$string,$matches);
print_r($matches);
//辦法三
preg_match_all('/<a[^>]*>[^<]*</a>/i',$string,$matches);
print_r($matches);
//辦法四
preg_match_all('/<a.+?>check user</a>/is',$str,$arr);
print_r($arr);
PHP應用以上就是php批量刪除超鏈接的四種辦法,希望對大家的學習有所幫助.
歡迎參與《PHP編程:php批量刪除超鏈接的實現方法》討論,分享您的想法,維易PHP學院為您提供專業教程。
轉載請注明本頁網址:
http://www.snjht.com/jiaocheng/8575.html