$needle = array("Arr","Arr:","Arrang");
$haystack = " Arr is the proper way of Arr.";
echo str_replace($needle, "Arrangement", $haystack);
Prints: Arrangement is the proper way of Arrangement
Want: Arrangement is the proper way of Arr.
Use preg_replace with an implode and delimiter for your array. The delimiter \s| acts as an or statement with the regex pattern that your array creates:
$needle = array("Arr","Arr:","Arrang");
$haystack = "Arr: is the proper way of Arr.";
echo preg_replace("/".implode("\s|",$needle)."\s/", "Arrangement ", $haystack, 1);
Result:
Arrangement is the proper way of Arr.
$haystack = "Arr is the proper way of Arr:";, still output shows Arrangement is the proper way of Arr."Arr","Arr:","Arrang" all these to be replaced, I think @Rich
Arrangementement is the proper way of Arrangementement