Useful notes & manuals
from the
world wide web
L:
P:
Register now!
Convert links into clickable hyperlinks PHP
Solution from: http://www.totallyphp.co.uk/code/convert_links_into_clickable_hyperlinks.htm Created by tlw on 09.06.2023 @ 10:19

<?php

function makeClickableLinks($text) {

$text = eregi_replace('(((f|ht)tp://)[-a-zA-Z0-9@:%_+.~#?&//=]+)',
'<a href="1">1</a>', $text);
$text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)',
'1<a href="http://2">2</a>', $text);
$text = eregi_replace('([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})',
'<a href="mailto:1">1</a>', $text);

return $text;

}

// Usage

// Email address example
$text = "you@example.com";
echo makeClickableLinks($text);

echo "

";

// URL example
$text = "http://www.example.com";
echo makeClickableLinks($text);

echo "

";

// FTP URL example
$text = "ftp://ftp.example.com";
echo makeClickableLinks($text);

?>

link   url   parse   convert   html   text   plain
 
Created by THE LOST WEB © 2009-2012