网络营销电子商务研究中心

网络营销电子商务研究中心 (https://www.0058.net/index.php)
-   PHP (https://www.0058.net/forumdisplay.php?f=75)
-   -   如何用php删除越级链接且保留文字? (https://www.0058.net/showthread.php?t=4383)

topvip 2012-07-10 08:11 AM

如何用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)


All times are GMT +8. The time now is 10:48 AM.

Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.