Re: string highlight
| From: | David Duong | Date: | Tue, 07 Jun 2005 23:30:47 +0000 |
| Subject: | Re: string highlight | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-216595@lists.php.net to get a copy of this message | ||
David Duong wrote:
Sebastian wrote:i'm looking for a function that can highlight certain search terms in a string. anyone have something already made that i can plugin to my exisiting code? I found a couple but they do not work very well.. some break html code if the string contains the keywords in the html. thanks.You can use str_replace to "highlight" the search terms. For example, you could use the following code for each search term (this function also accepts arrays, see http://php.net/str_replace): str_replace ($search_term, "<b>$search_term</b>", $body_text); - David I forgot to mention that if you wanted to have a highlighting effect, you will need to use stylesheets.