How to replace a set of characters in a string with a random set?
<p>Let's say I have a basic string of characters:</p>

<pre><code>$string = "abcdeffedcbaabcdef";
</code></pre>

<p>What I want to do is search for a, c, and f, and then replace them with <em>any one</em> of these characters:</p>

<pre><code>$replaceChars = array("1", "2", "3");
</code></pre>

<p>So as I search the string, each time I hit one of the characters I want to replace, I want to randomly pick from the pool of replacement characters, and then move onto the next character to replace and randomly select again, and so on...</p>

<p>I should end up with something like:</p>

<pre><code>$string = "2b1de32ed1b21b2de3";
</code></pre>

<p>I can't quite make it come together, though. I think I want to use <code>array_rand()</code> maybe with some kind of foreach loop, using <code>strpos()</code> to go through and find each instance of the characters to replace.</p>

<p>What's slowing me down is that it seems that there seem to be many methods for stepping through an array so that one can apply a <code>for</code> or <code>while</code> loop, I can't see how to step through a string one character at a time.</p>

<p>How would I do this?</p>
