I have a string.
$string = '<p>someText</p><li>someText</li><pre><p>someText</p></pre>';
I
want strip all tags except inside pre tag. for example output of $string is :
$string = 'someTextsomeText<pre><p>someText</p></pre>';
this is not working:
$string = strip_tags($string,<pre>);
Here is a solution - with an example string as:
Make pattern to find pre and contents within:
Use preg_match to find patter:
Split into parts BEFORE pre and AFTER pre:
Strip Tags from content before pre and after pre and combine together to final string: