note 19184 deleted from function.str-replace by aidan
| From: | aidan@php.net | Date: | Sun, 27 Jun 2004 13:53:01 +0000 |
| Subject: | note 19184 deleted from function.str-replace by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-71900@lists.php.net to get a copy of this message | ||
Note Submitter: info@wmelchior.com
----
dave's (dave@[nospam]netready.biz) solution for highlighting for non-case sensitive search
results works great with the exception that it leads to the unwanted result of also highlighting
html code if included with the $haystack.
So if you have :
$haystack = "I will break <b r> your heart";
(where <b r> should be the HTML line break)
and as search string
$needle = "br";
you get for:
echo highlight ( $needle, $haystack );
// "I will break [hilited]br[/hilited] your heart"
Simple solution (just for the sake of completeness , not a big deal):
1.) Remove ALL html or other formating code from $haystack
2.) Call
highlight ( $needle, $haystack );
3.) Replace $haystack with the highlighted version:
$haystack = highlight ($needle, $haystack);
4.) Do the html or other text conversions
like:
$haystack = str_replace("/n", "<b r>", $haystack);
5.)
echo $haystack;
Thanks again, Dave.