Make current function support click enabled phrases

Here is the sample text…

Writing this letter want to make the phrase my words here click enabled. Already handles www.address.com fine. What can you do?

Ok. Here’s the code…

function makeClickableLinks($text) {
$text = eregi_replace(’(((f|ht){1}tp://)[[email protected]:%+.~#?&//=]+)’,’\1’, $text);
$text = eregi_replace(’([:space:[{}])(www.[[email protected]:%
+.~#?&//=]+)’,’\1\2’, $text);
$text = eregi_replace(’([_.0-9a-z-][email protected]([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})’, ‘\1’, $text);
return $text;
}

Here’s what the code does…

It take a “www.address.com” or an “http://address.com” and makes it come back as click enabled.

This is what I need to add to the function…

Take the equivalent of something like, “my words here” and return a click enabled phrase, ie… “my words here” should take the viewer to address.com.

Can anyone make this happen for me?

Ok.

Thanks to all who looked at this problem. Found the fix myself over at
http://www.wallpaperama.com/forums/how-to-make-clickable-text-url-links-from-text-links-change-to-clicking-t641.html.

To any who are searching, here is the code.

function clickable_link($text)
{

this functions deserves credit to the fine folks at phpbb.com

$text = preg_replace(’#(script|about|applet|activex|chrome):#is’, “\1:”, $text);

// pad it with a space so we can match things at the start of the 1st line.
$ret = ’ ’ . $text;

// matches an “xxxx://yyyy” URL at the start of a line, or after a space.
// xxxx can only be alpha characters.
// yyyy is anything up to the first space, newline, comma, double quote or <
$ret = preg_replace("#(^|[\n ])([\w]+?://[\w#$%&~/.-;:=,[email protected][]+]*)#is", “\1<a href=”\2" target="_blank">\2", $ret);

// matches a “www|ftp.xxxx.yyyy[/zzzz]” kinda lazy URL thing
// Must contain at least 2 dots. xxxx contains either alphanum, or “-”
// zzzz is optional… will contain everything up to the first space, newline,
// comma, double quote or <.
$ret = preg_replace("#(^|[\n ])((www|ftp).[\w#$%&~/.-;:=,[email protected][]+]*)#is", “\1<a href=“http://\2” target=”_blank">\2", $ret);

// matches an [email protected] type address at the start of a line, or after a space.
// Note: Only the followed chars are valid; alphanums, “-”, “" and or “.”.
$ret = preg_replace("#(^|[\n ])([a-z0-9&-
.]+?)@([\w-]+.([\w-.]+.)*[\w]+)#i”, “\1<a href=“mailto:\[email protected]\3”>\[email protected]\3”, $ret);

// Remove our padding…
$ret = substr($ret, 1);
return $ret;
}

Sponsor our Newsletter | Privacy Policy | Terms of Service