Since str_replace() matches \":Name\" two times in \":Name :Name_en\" I want to match the results for the whole word only. I wanted to switch to preg_repl
str_replace()
preg_repl
you can use space, to replace its common to find space between sentence words.
$str = ":Name :Name_en"; echo $str; // The final int limits the function to a single replace. $str = str_replace(':Name ', 'Test', $str); echo $str;