Hello. There is an array with words that need to be replaced. And there is a text in which you need to replace the words from the array. Here is my code

$data = //берется из бд текст $Arr = Array(); $Arr[]="Классы"; $Arr[]="Ученики"; $Arr[]="Книги"; for($i = 0; $i < count($Arr); ++$i) { $data = str_replace($Arr[$i],"<i>".$Arr[$i]."</i><br>",$data); } print $data; 

Closed due to the fact that off-topic participants Dmitriy Simushev , aleksandr barakin , zRrr , VenZell , sercxjo Jun 2 '16 at 11:07 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - Dmitriy Simushev, aleksandr barakin, zRrr, VenZell, sercxjo
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • one
    and what's wrong with him? - splash58
  • does not replace the text - user209681
  • 2
    replaces - eval.in/577605 - splash58
  • one
    Could it be a matter of encoding? - user209681
  • one
    Yes maybe. And, apparently, most likely - splash58

1 answer 1

The code is correct. The problem was in the encoding of the file.