Im trying to replace html tags that are between pre tags. This is what I want it to do:
$str = '<pre><div>Get<p>rid</p> of html tags</div></pre>';
$str = preg_replace('#(<pre.*?>)/<[^<>]+>/(</pre>)#', '$1$2', $str);
echo $str;
It should responed with, “Get rid of html tags” in pre tags
I know for a fact that,
$str = preg_replace('#(<pre.*?>).*?(</pre>)#', '$1$2', $str);
works, but responds with empty pre tags.
I just need to remove all html tags in between the pre tags.
Here’s how I’d do it: