title: When to use strtr vs str_replace?
body: <p>I'm having a hard time understanding when <code>strtr</code> would be preferable to <code>str_replace</code> or vice versa. It seems that it's possible to achieve the exact same results using either function, although the order in which substrings are replaced is reversed. For example:</p>
  
  <pre><code>echo strtr('test string', 'st', 'XY')."\n";
  echo strtr('test string', array( 's' =&gt; 'X', 't' =&gt; 'Y', 'st' =&gt; 'Z' ))."\n";
  echo str_replace(array('s', 't', 'st'), array('X', 'Y', 'Z'), 'test string')."\n";
  echo str_replace(array('st', 't', 's'), array('Z', 'Y', 'X'), 'test string');
  </code></pre>
  
  <p>This outputs</p>
  
  <pre><code>YeXY XYring
  YeZ Zring
  YeXY XYring
  YeZ Zring
  </code></pre>
  
  <p>Aside from syntax, is there any benefit to using one over the other? Any cases where one would not be sufficient to achieve a desired result?</p>