I have similar to Firepages' solution.
PHP Code:
function addLinks($var, $linkstyle){
$var = ereg_replace("([[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/])", "<a class=\"$linkstyle\" href=\"\\1\">\\1</a>", $var);
$var = ereg_replace("([_a-zA-z0-9\-]+(\.[_a-zA-z0-9\-]+)*\@" . "[_a-zA-z0-9\-]+(\.[a-zA-z]{1,3})+)", "<a class=\"$linkstyle\" href=\"mailto:\\1\">\\1</a>", $var);
return $var;
}
whatever you type in your cms (I am assuming you are using some cms)
http://www.link.com or
email@email.com, those will be turned to links.
When you want to edit text again, use this function before displaying want-to-edit data:
PHP Code:
function remLinks($var, $linkstyle){
$var = ereg_replace ("(<a class=\"$linkstyle\" href=\"[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]\">)([[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/])(</a>)","\\2", $var);
$var = ereg_replace ("(<a class=\"$linkstyle\" href=\"mailto:)([_a-zA-z0-9\-]+(\.[_a-zA-z0-9\-]+)*\@" . "[_a-zA-z0-9\-]+(\.[a-zA-z]{1,3})+)(\">)([_a-zA-z0-9\-]+(\.[_a-zA-z0-9\-]+)*\@" . "[_a-zA-z0-9\-]+(\.[a-zA-z]{1,3})+</a>)", "\\2", $var);
return $var;
}
I copied and modified above from my old CMS, so I hope it works properly. If not - give me a yel.
~Greg