This is my function:
function makeClickableLinks($s) {
return preg_replace('@(https?://([-\w\.]+[-\w])+(:\d+)?(/([\w/_\.#-]*(\?\S+)?[^\.\s])?)?)@', '<a href="$1" target="_blank">$1</a>', $s);
}
$description = $_POST['description'];
echo makeClickableLinks($description);
$_POST[‘description’] is a form textarea that will be inserted later into a MySQL table.
I want to allow users to create links within this input field. When I use this function, user inputted data that looks like this:
Whats up guys. Here's my website! Please check it out!!
<a href="google.com">hi</a>
Is now a clickable link, but links to:
http://(myurl).com/google.com
It thinks the link is a subdirectory. Any ideas? THankS!
As I understand you want to organize something like replacing the references in the user’s records, so that they referred to your site. Tray this regexp: