Voting

: three plus two?
(Example: nine)

The Note You're Voting On

admin at bwongar dot com
20 years ago
I didn't get the expected results from the other XHTML_highlight function, so I developed my own and it is much more efficient. The older one uses a preg_replace to replace the contents of the tag to within a span tag. The only preg_replace in my function pulls the color attribute, and puts it within a str_replace'd span tag.

<?php
function xhtml_highlight($str) {
$str = highlight_string($str, true);
$str = str_replace(array('<font ', '</font>'), array('<span ', '</span>'), $str);
return
preg_replace('#color="(.*?)"#', 'style="color: \\1"', $str);
}

?>

<< Back to user notes page

To Top