public static function highlightCode($string)
{
// regex pattern
$pattern = '/<code>.*?<\\/code>/is';
// find matches
if (preg_match_all($pattern, $string, $matches)) {
// loop matches
foreach ($matches[0] as $match) {
// encase content in highlight_string
$string = str_replace($match, highlight_string($match, true), $string);
// replace highlighted code tags in match
$string = str_replace(array('<code>', '</code>'), '', $string);
}
}
return $string;
}