可以用$str = preg_replace(“/]*href=[^>]*>|<\/[^a]*a[^>]*>/i”,””,$strhtml); 这段来实现需求,如果想要更多解决方法,可以参看以下的。
1、删除内容中的超链接
<br />ereg_replace(']*)>([^<]*)','<font color="red">\\2</font>',$content);<br />ereg_replace("]*>|<\/a>","",$content);<br />
2、消除包含特定词的超链接
<br />$find="this string is my find";<br />$string='<font color="red">替换掉了</font>';//将超链接替换成的内容<br />echo ereg_replace(']*)>([^]*)','<font color="red">\\2</font>',$content);<br />
3、获取超链接文本内容
<br />//方法一<br />preg_match_all('/[nrn]*(check user)[nrn]*/i',$string,$matches);</p><p>//方法二<br />preg_match_all('/check user/i',$string,$m<strong>)本文来(源gaodai#ma#com搞@@代~&码*网2</strong><pre>搞代gaodaima码
atches);
print_r($matches);
//方法三
preg_match_all(‘/]*>[^<]*/i',$string,$matches);
print_r($matches);
//方法四
preg_match_all(‘/check user/is’,$str,$arr);
print_r($arr);
//方法五
preg_match_all(‘/check user/is’,$str,$arr);
print_r($arr);
我用了这句 $year = preg_replace(“/]*href=[^>]*>|<\/[^a]*a[^>]*>/i”,””,$yearstr);