Highlighting a search string in HTML text
Several hundred user notes on the str_replace page later, and we have a function that provides a variety of text highlighting options for plaintext or HTML strings.
This function, for example, would allow you to parse a HTML document and wrap certain words in HTML tags to direct the users attention.
Let’s do a quick example:
This code would produce the following output:
This is a site about PHP and SQL
Link to php
I like to eat bananas with my nana!
With custom highlighting!
I am a link