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