<?php
function renderPre($input) // Function to escape html brackets within PRE tags.
{
return preg_replace('/<pre>(.*?)<\/pre>/ise', "'<pre class=\"brush: php\">' . htmlspecialchars('$1') . '</pre>'", $input);
}
$s = 'hello <pre>I like <em>apples</em> & oranges</pre>';
echo renderPre($s);