Php version 5.3

There is a text received from the database. There are words obtained also from the database. It is necessary to replace the words with *** in the text that coincide with the words that are not case sensitive. If the register is taken into account, everything works out. str_ireplace this function also does not work. Understanding, I realized that the case is in Cyrillic and in UTF-8 encoding. I want to notice, if I check which encoding is in each of the variables, then everywhere is UTF-8 except $ str_replace, there is ASCII. The mb_eregi_replace function does not work either.

If the text and words are written in the code itself, without getting it from the database, then everything goes as it is necessary without regard to case.

$msg = preg_replace("/($key)/iu", $str_replace, $msg); // $key - слово, которое необходимо заменить // $str_replace - *** (звездочки) // $msg - Текст $msg = preg_replace("/(сделаю)/iu", '***', "я Сделаю"); // Этот вариант рабочий. 

    1 answer 1

     $msg = preg_replace($key, $str_replace, $msg); 
    • $ msg = preg_replace ($ key, $ str_replace, $ msg); so generally NULL - Ron Rom