$TOPIC_CONTENT = preg_replace("!<code>(.+)</code>!is","<div style='color: #00FF00;
background-color: #000000; border-radius: 5px; margin: 5px;"<pre>".htmlspecialchars("$0")."</pre></div>",$TOPIC_INFO->content);
How can I get this to work? I have no idea how to pull this off, and I know my current way is invalid.
Use
preg_replace_callback. Be a little careful with your regex .. I think you want to use.+?instead of just.+. The usual mantra is "don’t parse html with regex," but for something as simple as this I don’t see the harm.