Using a function I tried to buid using 2 other functions I have run into a problem trying to integrate them together;
http://us3.php.net/manual/en/function.highlight-string.php
PHP
<?php
function bbcode($s)
{
$s = str_replace("]\n", "]", $s);
$match = array('#\[php\](.*?)\[\/php\]#se');
$replace = array("'<div>'.highlight_string(stripslashes('$1'), true).'</div>'");
return preg_replace($match, $replace, $s);
}
?>
function bbcode($s)
{
$s = str_replace("]\n", "]", $s);
$match = array('#\[php\](.*?)\[\/php\]#se');
$replace = array("'<div>'.highlight_string(stripslashes('$1'), true).'</div>'");
return preg_replace($match, $replace, $s);
}
?>
And
PHP
<?php
function xhtml_highlight($str) {
$str = highlight_string($str, true);
$str = str_replace(array('<font ', '</font>'), array('<span ', '</span>'), $str);
return preg_replace('#style="color:(.*?)"#', 'style="color: \\1"', $str);
}
?>
function xhtml_highlight($str) {
$str = highlight_string($str, true);
$str = str_replace(array('<font ', '</font>'), array('<span ', '</span>'), $str);
return preg_replace('#style="color:(.*?)"#', 'style="color: \\1"', $str);
}
?>
My function at the moment is;
PHP
function xhtml($str) {
$str = highlight_string($str, true);
// $str = substr($str, 29, -15);
$str = str_replace(array('<font ', '</font>','<code>','</code>'), array('<span ', '</span>','<div class="php-code">','</div>'), $str);
return preg_replace('#style="color:(.*?)"#', 'style="color: \\1"', $str);
}
$str = highlight_string($str, true);
// $str = substr($str, 29, -15);
$str = str_replace(array('<font ', '</font>','<code>','</code>'), array('<span ', '</span>','<div class="php-code">','</div>'), $str);
return preg_replace('#style="color:(.*?)"#', 'style="color: \\1"', $str);
}
Which is just highlighting the entire content, I want to only highlight the code between the [ php ] tags, everything I try to do this doesn't work so I was wondering if someone could help me a lil'.
Cheers