Inserting characters into a string - most efficient
<p>I need to insert a character into a string, A, every place there is a character B.</p>

<p>For example xxxxxxxxBxxxxxxxxxxxxxxxxxBxxxxxxxxxxxxB</p>

<p>becomes</p>

<p>xxxxxxxxxxxABxxxxxxxxxxxxxxxABxxxxxxxxxxxxxxxxxxxAB</p>

<p>I see that Javascript (replace) and PHP (str_replace) have replace functions, so that I can just replace each occurence of B with AB.</p>

<p>Is this the most efficient way to do this?</p>
