How to remove a link from content in php?

前端 未结 7 833
悲哀的现实
悲哀的现实 2020-12-24 09:12

How can i remove the link and remain with the text?

text text text. 
7条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-24 09:49

    I suggest you to keep the text in link.

    strip_tags($text, '
    ');

    or the hard way:

    preg_replace('#(.*?)#i', '\1', $text)
    

    If you don't need to keep text in the link

    preg_replace('#.*?#i', '', $text)
    

提交回复
热议问题