title: Replace spaces in href with %20 in php
body: <p>i want to replace every space in a link with %20.</p>
  
  <pre><code>&lt;a href="Replace the spaces here"&gt;Some text&lt;/a&gt;
  </code></pre>
  
  <p>i want to get This:</p>
  
  <pre><code>&lt;a href="Replace%20the%20spaces%20here"&gt;Some text&lt;/a&gt;
  </code></pre>
  
  <p>not this:</p>
  
  <pre><code>&lt;a%20href="Replace%20the%20spaces%20here"&gt;Some%20text&lt;/a&gt;
  </code></pre>
  
  <p>How to do this?
  preg_replace?
  Solution (because I cant post an answer):</p>
  
  <pre><code>$search= '(href="(.*?)")s';
  $replace= '';
  $newstring= preg_replace_callback($search,create_function('$treffer','urlencode($treffer[0]);'),$string);
  </code></pre>