php search and replace but not duplicate.
P粉481815897
P粉481815897 2023-07-17 18:41:56
0
1
502

I want to replace the word "Dozenten" with "Dozentin" and the word "Dozent" with "Dozenten" using PHP. The problem is, "Dozent" appears in both words. I can't continue using `str_replace`. How to avoid getting results similar to "Dozentenin"?

P粉481815897
P粉481815897

reply all(1)
P粉265724930

你可以使用`strtr`函数来实现,它可以在字符串中进行子字符串的翻译(替换):

<?php 
$s = "Dozenten Dozent Dozent Dozenten"; 
echo strtr($s, array("Dozenten" > "Dozentin", "Dozent" => "Dozenten")); 
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template