Forum Moderators: coopster
function format($txt) {
$txt = preg_replace("/\[php\](.*?)\[\/php\]/is", "<div id=\"phpcode\">" . highlight_string("\\1", true) . "</div>", $txt);
return nl2br($txt);
}
This will output the code but it misses of the first "<?php" so it doesnt highlight the code! This is what the source looks like:
<div id="phpcode"><code><font color="#000000"><br />
<?php<br />
echo "test";<br />
?></font><br />
</code></div>
Any help?
<div id="phpcode"><code><font color="#000000">
[b][php][/b]
echo "test";
[b][/php][/b]</font>
</code></div>
This is what your regex seems to be searching for (I think--I'm still a beginner when it comes to Regular Expressions ;))
function format($txt) {
$txt = preg_replace("/<(.*?)>/is", "<\\1>", $txt);
$txt = preg_replace("/\[php\](.*?)\[\/php\]/is", "<div id=\"phpcode\">" . highlight_string("\\1", true) . "</div>", $txt);
return nl2br($txt);
}
try that. Might work.