I have one unsolved case. I need to highlight some $search text from $sentence.
$result=preg_replace("/\p{L}*?".preg_quote($search)."\p{L}*/ui", "<strong style='color:yellow'>$0</strong>", $sentence);
This function does everything good, finds every appearance of substring, but it highlights (replaces) not only the part of word which contains the substr, but the whole word (from whitespase to whitespace).
For example:
$sentence='This is the sentence to be searhed through';
$search = 'sent';
echo $result gives "This is the **sentence** to be searhed through"
But I need
"This is the sentence to be searhed through"
Can somebody help me understanding what i did wrong? Thanks in advance.