Suppose there\'s a string \"foo boo foo boo\" I want to replace all fooes with boo and booes with foo. Expected output is \"boo foo boo foo\". What I get is \"foo foo foo fo
$a = "foo boo foo boo"; echo "$a\n"; $a = str_replace("foo", "x", $a); $a = str_replace("boo", "foo", $a); $a = str_replace("x", "boo", $a); echo "$a\n";
note that "x" cannot occur in $a