 <p>@Damith @Rahul Nikate @Willem van Rumpt</p> <p>Your solutions generally work. There are particular cases with different result:</p> <pre><code>echo strtr("hi all, I said hello","ah","ha"); </code></pre> <p>returns</p> <pre><code>ai hll, I shid aello </code></pre> <p>while your code:</p> <pre><code>ai all, I said aello </code></pre> <p>I think that the php <code>strtr</code> replaces the chars in the input array at the same time, while your solutions perform a replacement then the result is used to perform another one. So i made the following modifications:</p> <pre><code> private string MyStrTr(string source, string frm, string to) { char[] input = source.ToCharArray(); bool[] replaced = new bool[input.Length]; for (int j = 0; j &lt; input.Length; j++) replaced[j] = false; for (int i = 0; i &lt; frm.Length; i++) { for(int j = 0; j&lt;input.Length;j++) if (replaced[j] == false &amp;&amp; input[j]==frm[i]) { input[j] = to[i]; replaced[j] = true; } } return new string(input); } </code></pre> <p>So the code</p> <pre><code>MyStrTr("hi all, I said hello", "ah", "ha"); </code></pre> <p>reports the same result as php:</p> <pre><code>ai hll, I shid aello </code></pre>