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 foo". How to get expected output rather than current one?
$a = "foo boo foo boo";
echo "$a
";
$b = str_replace(array("foo", "boo"), array("boo", "foo"), $a);
echo "$b
";
//expected: "boo foo boo foo"
//outputs "foo foo foo foo"
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…