So I'm making a search function for comments. Someone else here helped me with the SQL query. What I also want to do is to highlight the search query text in the results.
The results are stored as HTML inside a $variable
.
How can I wrap the search query text inside a <span>
tag for example, without messing up the html.
for eg. the search query can be foo bar
and the output can look like:
<p>bla bla foo bar bla</p>
so it should be something like:
<p>bla <span class="highlight">foo bar</span> bla bla</p>