title: How can I replace the "+" plus sign with its corresponding url encoding of "%2B"?
body: <p>I'm having some trouble replacing the "+" sign with its urlencoded string of "%2B".  How can I do this?</p>
  
  <p>This is what I've tried:</p>
  
  <p>Text Entered into text box:</p>
  
  <pre><code>plus(+)
  </code></pre>
  
  <p>I then urlencode the string:</p>
  
  <pre><code>$string = urlencode($string);
  </code></pre>
  
  <p>String now looks like:</p>
  
  <pre><code>plus%28+%29
  </code></pre>
  
  <p>I want to have the "+" urlencoded, or else when I urldecode() the data to display in browser I end up with:</p>
  
  <pre><code>plus( ) 
  </code></pre>
  
  <p>because urldecode() interprets the "+" to be a space.</p>
  
  <p>I tried using php's str_replace() but I keep getting a "NULL" returned as the value for "$new_string":</p>
  
  <pre><code>$new_string = str_replace('+', '%2B', $string);
  </code></pre>
  
  <p>Any ideas?  </p>
  
  <p>Thanks in advance!</p>