note 48742 added to function.highlight-string
| From: | admin at bwongar dot com | Date: | Wed, 05 Jan 2005 23:11:56 +0000 |
| Subject: | note 48742 added to function.highlight-string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-82805@lists.php.net to get a copy of this message | ||
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);
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.highlight-string.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+48742
Delete -- http://master.php.net/manage/user-notes.php?action=delete+48742&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48742&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48742&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48742&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48742&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48742&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+48742&report=yes
Search -- http://master.php.net/manage/user-notes.php