note 44983 added to function.preg-replace
| From: | aidan@php.net | Date: | Sun, 22 Aug 2004 14:01:25 +0000 |
| Subject: | note 44983 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-75110@lists.php.net to get a copy of this message | ||
Here is a simple function for highlighting a needle in text. It is careful to not replace text in
HTML tags (unless specified).
http://aidan.dotgeek.org/lib/?file=function.str_highlight.php
Example: The google method of highlighting
<?php
$text = "Here is some text with a search term";
$needle = "search term";
echo str_highlight($text, $needle);
?>
Output:
Here is some text with a <strong>search term</strong>
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+44983
Delete -- http://master.php.net/manage/user-notes.php?action=delete+44983&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+44983&report=yes
Search -- http://master.php.net/manage/user-notes.php