Click here to Skip to main content
15,898,036 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi to all! I will like to change URL entered as strings in a form input to be changed to hyperlink when it's submitted.

For example

hi this is link http://www.codeproject.com/


changes to

hi this is link http://www.codeproject.com/
Posted
Updated 7-May-13 6:45am
v2
Comments
Richard C Bishop 7-May-13 12:26pm    
You will need to clarify your thread. None of that makes any sense. Use propper capitalization, spelling, grammar and punctuation.

1 solution

This should do the trick
PHP
function makeClickableLinks($s)
{
    return preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.-]*(\?\S+)?)?)?)@', '<a href="$1">$1</a>', $s);
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900