I'm getting content from database:
$data="some markup <pre> <code> some code </code> </pre> some markup"
What I want to do is following
If $data has <pre> <code> </code> </pre>
inside, then do something and pass some code
through htmlspecialchars() function. Then merge as it was before. Something like:
$data="some markup <pre> <code> htmlspecialchars(some code) </code> </pre> some markup"
Can't figure out how to do it..
I think you probably want to parse the HTML with DOM, then find all instances where there's code between <pre>
and <code>
tags.
Then you can take that text and do a str_replace()
on it.