tag and its content from HTML using php
Below is the text I need to remove tags from
Addiction, stress and subjective wellbeing
The need and signi
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 keepText to remove
";
$result = preg_replace('/]*>(.*?)<\/p>/i', '', $title);
echo $result;
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?