title: swap two words in a string php
body: <p>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?</p>
  
  <pre><code>    $a = "foo boo foo boo";
      echo "$a\n";
      $b = str_replace(array("foo", "boo"), array("boo", "foo"), $a);
      echo "$b\n";
      //expected: "boo foo boo foo"
     //outputs "foo foo foo foo"
  </code></pre>