php去除超鏈接的方法:1、刪除html文本內(nèi)容中的超鏈接,代碼為【ereg_replace("]*>|<\\\\ a="">","",$content)】;2、清除包含指定關(guān)鍵詞的超鏈接。
php去除超鏈接的方法:
清除掉一段html文本內(nèi)容中的超鏈接最常見的寫法可以如下:
代碼如下:
$str=preg_replace("/<a[^>]*href=[^>]*>|<\\\\/[^a]*a[^>]*>/i","",$content);相關(guān)學(xué)習(xí)推薦:php編程(視頻)
1、刪除html文本內(nèi)容中的超鏈接
代碼如下:
ereg_replace("<a [^>]*>|<\\\\/a>","",$content);2、清除包含指定關(guān)鍵詞的超鏈接
$find="this string is my find"; $string='<font color="red">這段內(nèi)容將要被替換掉</font>';//將超鏈接替換成的內(nèi)容 echo ereg_replace('<a([^>]*)>([^<]*'.$find.'[^>]*)</a>','<font color="red">\\\\\\\\2</font>',$content);下面同時分享幾種獲取html文本內(nèi)容中的超鏈接的文本內(nèi)容方法:
//方法一 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);相關(guān)推薦:編程視頻課程