whats wrong with this php hyperlinking validation script
<p>I have a website were users enters articles and their reference(like wikipedia). The reference which were saved in the database includes both web address and non web addresses.I got a hyperlink validation script from net ,below is the script and this is my similar but not same query in this site
<a href="http://stackoverflow.com/questions/7789562/how-to-hyperlink-a-web-address-or-a-non-web-address-in-php">How to hyperlink a web address or a non web address in php</a></p>

<pre><code> //url validation

 if (preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i',  $url))

{
echo("&lt;br&gt;&lt;a rel=nofollow  target=_blank href=". urlencode($row['ref'])." class=art&gt;$row[ref]&lt;/a&gt;"); 


} 
 //if it is not a url
 else {
  echo("&lt;br&gt;&lt;a rel=nofollow  target=_blank href='http://www.google.com/search?q=".urlencode($row['ref'])."' class=art&gt;$row[ref]&lt;/a&gt;");
}
</code></pre>

<p>script is working properly..but it seems the hyperlinking of webaddress is not happening(non webaddress working fine)</p>

<pre><code> eg: if $url is http://www.washingtonpost.com
</code></pre>

<p>this script is hyperlinking as</p>

<pre><code>     www.mywebsite.com/http://www.washingtonpost.com
</code></pre>

<p>i actually want</p>

<pre><code>      http://www.washingtonpost.com
</code></pre>

<p>can you please help me and also advanced thanks for your help.</p>
