How do I remove

tag and its content from HTML using php

后端 未结 7 1232
既然无缘
既然无缘 2021-02-06 06:22

Below is the text I need to remove

tags from

Addiction, stress and subjective wellbeing

The need and signi

7条回答
  •  旧时难觅i
    2021-02-06 06:41

    You must use this regular expression to catch

    tag and all of its content:

    '/]*>(.*?)<\/p>/i'
    

    Working example to catch and remove

    tag and all of its content:

    $title = "
    Text to keep

    Text to remove

    "; $result = preg_replace('/]*>(.*?)<\/p>/i', '', $title); echo $result;

    Please see live demo on Codepad

    If you want to use regular expressions to parse HTML - then you will not be able to do this.

    Read more about your matter here: How do you parse and process HTML/XML in PHP?

提交回复
热议问题