This question has already been answered:

It is necessary to replace the same, but with additives. In English it works, with the Russian problem (does not change). tested here . I tried with mb_ereg_replace, but it also did not work ....

$text = "Слово слоВо Test tesT"; $word = 'слово'; $text = preg_replace('/(' . $word . ')/i', '<b>\\1</b>', $text); $word = 'test'; $text = preg_replace('/(' . $word . ')/i', '<i>\\1</i>', $text); echo $text; 

Reported as a duplicate by members user194374, AK , Alex , aleksandr barakin , fori1ton Jan 5 '17 at 13:31 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

1 answer 1

Solution: you need to use the modifier "u":

 '/(' . $word . ')/iu'