Replace every other occurence with different replacements
<p>I have a string that looks something like this:</p>

<pre><code>$post = "Test $asd$ lol test asd $test$";
</code></pre>

<p>I want it to become:</p>

<pre><code>$post = "Test [bb]asd[/bb] lol test asd [bb]test[/bb]";
</code></pre>

<p>Which is the easiest/best way to accomplish this? Note that the number of $ occurrences differs from time to time. The basic idea is to replace every other occurrence with [b] respectively [/bb].</p>

<p>I hope you understand.</p>
