title: How to replace 2 strings (with eachother) simultaneously in PHP
body: <p>What I'm trying to do is very simple, but I'm looking to do it most efficiently, preferably using php builtin fns.</p>
  
  <pre><code>$str = '1234';
  echo replace_function(array('1','3'),array('3','1'),$str);
  
  // output: 3214
  </code></pre>
  
  <p>str_replace,preg_replace would result in 1214, which means it goes through the arrays, replacing matched strings. I'm looking for a solution to simultaneously "switch" these two (or more) strings.</p>
  
  <p>any ideas?</p>