The updated question, unfortunately, I have not explained this before.
Details:
I have a database with several rows, and each row has tons of data, but each one has tags <pre><code></code></pre>in random order.
example:
$string = "
<h2>Heading 2</h2>
Something
<pre><code> alot of html and other code here </code></pre>
something something
<pre><code> alot of html and other code here </code></pre>
";
NOTE: the line will not be in the same order each time, there may be more or less tags <pre><code>
now I want to display the code inside the tags <pre><code></code><pre>as plain text, and you know that I need to convert everything "<"with "<"and ">"with ">", but the problem is that there are other tags outside the preliminary tags. if I use htmlspecialchars($string);, it will show all tags as plain text, even h2 tag and pre tags.
, , htmlspecialchars() .