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;