title: How to replace http:// or www with <a href.. in PHP
body: <p>I've created this regex</p>
  
  <pre><code>(www|http://)[^ ]+
  </code></pre>
  
  <p>that match every <em>http://...</em> or <em>www....</em> but I dont know how to make preg_replace that would work, I've tried</p>
  
  <pre><code>preg_replace('/((www|http://)[^ ]+)/', '&lt;a href="\1"&gt;\1&lt;/a&gt;', $str);
  </code></pre>
  
  <p>but it doesn't work, the result is empty string.</p>