[ create a new paste ] login | about

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

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


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: