Replace characters in PHP but no more than once
<p>What's best performing script to replace certain characters with a <em>maximum</em> of one other character?</p>

<p>For instance, I need to replace all spaces (<code></code>) and commas (<code>,</code>) with plus signs (<code>+</code>) <strong>but no more than one plus sign at a time</strong></p>

<p>So: <code>the,quick, brown  fox jumped,   over the,, lazy, dog</code></p>

<p>Would become: <code>the+quick+brown+fox+jumped+over+the+lazy+dog</code></p>
