title: Find url from string with php
body: <p>following code is used to find url from a string with php. Here is the code:</p>
  
  <pre><code>$string = "Hello http://www.bytes.com world www.yahoo.com";
  preg_match('/(http:\/\/[^\s]+)/', $string, $text);
  $hypertext = "&lt;a href=\"". $text[0] . "\"&gt;" . $text[0] . "&lt;/a&gt;";
  $newString = preg_replace('/(http:\/\/[^\s]+)/', $hypertext, $string);
  echo $newString;
  </code></pre>
  
  <p>Well, it shows a link but if i provide few link it doesn't work and also if i write without http:// then it doesn't show link.  I want whatever link is provided it should be active, Like stackoverflow.com. </p>
  
  <p>Any help please.. </p>