preg_replace with two arrays <p>I've have a problem with <code>preg_replace()</code> using arrays.</p> <p>Basically, I'd like to transpose this string ;</p> <pre><code>$string = "Dm F Bb F Am"; </code></pre> <p>To </p> <pre><code>$New_string = "F#m D D A C#m"; </code></pre> <p>Here is what I do: </p> <pre><code>$Find = Array("/Dm/", "/F/", "/Bb/", "/Am/", "/Bbm/", "/A/", "/C/"); $Replace = Array('F#m', 'A', 'D', 'C#m', 'Dm', 'C#', 'E'); $New_string = preg_replace($Find, $Replace, $string); </code></pre> <p>But I get this result instead :</p> <p>E##m E# D E# E#m</p> <p>Problem is that every match is replaced by the following, something like this happens (example for E##m):</p> <p>Dm -> F#m -> A#m -> C##m -> E##m</p> <p>Is there any solution to simply change 'Dm' to 'F#m', "F" to "A", etc ?</p> <p>Thank you !</p>