PDA

View Full Version : 如何用php删除越级链接且保留文字?


topvip
2012-07-10, 08:11 AM
有2个方法,第一个是用strip_tags() will strip HTML tags来实现:
strip_tags($text, '<br>');

另一个方法,用正则表达:
preg_replace('#<a.*?>(.*?)</a>#i', '\1', $text)

当然,如你不想要保留文字,可以这且操作:
preg_replace('#<a.*?>.*?</a>#i', '', $text)