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
Perhaps using a temporary value like coo.
coo.
sample code here,
$a = "foo boo foo boo"; echo "$a\n"; $b = str_replace("foo","coo",$a); $b = str_replace("boo","foo",$b); $b = str_replace("coo","boo",$b); echo "$b\n";