View Single Post
  #1   IP: 112.87.0.17
Old 2012-07-10, 08:11 AM
topvip topvip is offline
超级版主
 
Join Date: 2006-01-04
Posts: 1206
topvip 正向着好的方向发展
Default 如何用php删除越级链接且保留文字?

有2个方法,第一个是用strip_tags() will strip HTML tags来实现:
Code:
strip_tags($text, '<br>');
另一个方法,用正则表达:
Code:
preg_replace('#<a.*?>(.*?)</a>#i', '\1', $text)
当然,如你不想要保留文字,可以这且操作:
Code:
preg_replace('#<a.*?>.*?</a>#i', '', $text)
Reply With Quote