I have a variable $example that has html content that I need to render/echo to screen. But before rendering to screen, I want to remove certain elements. For instance the structure of the $example variable is:
<form> some stuff here... </form><p>hi there</p><div></div>
I want to remove the form element from the $example variable before rendering. I know I can do this using regular expressions, but what is a better way to do it in php? Also, is there a function in php like strip_tags, which can be passed exactly the tag that it needs to strip? My question is not related to stripping unsafe tags or cleaning up html, it is just that i want to remove certains elements from a variable before outputting. As a generatlization, how do i remove only those divs from the $example variable that have a particular class added to them?