[ create a new paste ] login | about

Link: http://codepad.org/doIwcpnw    [ raw code | output | fork ]

PHP, pasted on Oct 15:
1
2
3
4
5
6
7
8
9
10
11
<?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);


Output:
1
hello <pre class='brush: php'>I like &lt;em&gt;apples&lt;/em&gt; &amp; oranges</pre>


Create a new paste based on this one


Comments: