サンプルコードがあります:
$text = "abc ABC def ghi Abc aBc xyz";
$search = "abc"
$string = str_replace(" ".trim($search)." ", 'DEF', $text);
echo $string;
結果は次のとおりです。" abc ABC def ghi DEF aBc xyz
"//Abcの変更のみ
しかし、結果は正確には次のようになります: " abc DEF def ghi DEF DEF xyz
"
それを修正する方法は?