Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is some sample code that should do the trick:</p> <pre><code>$parsethis = ''; $parsethis .= "Hi there, this is some text and this is a picture &lt;img src='http://www.google.no/images/srpr/logo3w.png' /&gt;\n"; $parsethis .= "Below I will show you the code how to do this image:\n"; $parsethis .= "\n"; $parsethis .= "&lt;code&gt;\n"; $parsethis .= " &lt;img src='http://www.google.no/images/srpr/logo3w.png' /&gt;\n"; $parsethis .= "&lt;/code&gt;\n"; $pattern = '#(&lt;code[^&gt;]*&gt;(.*?)&lt;/code&gt;)#si'; $finalstring = preg_replace_callback($pattern, "handle_code_tag", $parsethis); echo $finalstring; function handle_code_tag($matches) { $ret = '&lt;pre&gt;'; $ret .= str_replace(array('&lt;', '&gt;'), array('&amp;lt;', '&amp;gt;'), $matches[2]); $ret .= '&lt;/pre&gt;'; return $ret; } </code></pre> <p>What it does:</p> <p>First using <code>preg_replace_callback</code> I match all code inside <code>&lt;code&gt;&lt;/code</code> sending it to my callback function <code>handle_code_tag</code>which escapes all less-than and greater-than tags inside the content. The matches array wil contain full matched string in <a href="https://i.stack.imgur.com/mpJkt.png" rel="nofollow noreferrer">1</a> and the match for <code>(.*?) in [2].</code>#si` <strong>s</strong> means match . across linebrakes and <strong>i</strong> means caseinsensitive</p> <p>The rendered output looks like this in my browser: <img src="https://i.stack.imgur.com/mpJkt.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload