I have a sample code:
$text = "abc ABC def ghi Abc aBc xyz";
$search = "abc"
$string = str_replace(" ".trim($search)." ", 'DEF', $text);
echo $string;
And result is: “abc ABC def ghi DEF aBc xyz” // only Abc change
But result exactly is: “abc DEF def ghi DEF DEF xyz“
How to fix it ?
You can using: