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.Currently i am hyper linking the script using google’s search?q and its working properly.
echo("<br><a rel=nofollow target=_blank href='http://www.google.com/search?q=".urlencode($row['ref'])."' class=art>$row[ref]</a>");
i want to know whether its possible to automatically detect my reference as a web address or not .if it is a web address then when users click to the hyperlink it goes directly to that website and if not it should hyperlink to google search.
eg:
if user enters this link as reference.hyper link should be to this web address
http://www.washingtonpost.com/sports/capitals
or
www.washingtonpost.com/sports/capitals
or
washingtonpost.com/sports/capitals
or if the user enters reference as below
washingtonpost+sports+capitals
it should go to googles search?q
advance thanks for your help
You would use a regular expresion to see if it is a link and make it a link. Regular expression also makes sure it is valid syntax for a link.