I'm trying to replace parts of my string. But I met a problem when my search string start with same character:
$string = "Good one :y. Keep going :y2";
$str = str_replace(array_keys($my_array), array_values($my_array), $string);
$my_array= array(":y" => "a", ":y2" => "b");
ouput:
Good one a. Keep going a2
I need my str_replace()
to match the word correctly/exactly.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…