Lets say I have the following string (from a much larger string with multiple similiar strings)
$str = '<div class='testdiv remove'>randomtext</div>
<div class='testdiv'>randomtext <a href="#">randomtext</a></div>';
The class 'remove' was added through a javascript function. How would I remove all elements of the class 'remove' and all links so that the string becomes this:
$str = '<div class='testdiv'>randomtext </div>';
I can't use jquery to remove these tags since I have to feed this into a php library function. How would I remove these?