There is a PHP function that can highlight a word regardless of case or accents, but the string returned will be the original string with only the highlighting?
For example:
Function highlight($string, $term_to_search){
// ...
}
echo highlight("my Striñg", "string")
// Result: "my <b>Striñg</b>"
Thanks in advance!
What I tried:
I tried to do a function that removed all accents & caps, then did a "str_replace" with the search term but found that the end result logically had no caps or special characters when I expected it to be just normal text but highlighted.
2
Answers
you can try str_ireplace
You can use ICU library to normalize the strings. Then, look for term position inside handle string, to add HTML tags at the right place inside original string.