Yesterday I discovered that all ereg, eregi functions will be removed from php very soon. I am shocked. It will take weeks and months of work to replace all these functions in the scripts.
Now I am looking for a function to make URLs and emails clickable and then to convert clickable links back to plain text URLs and emails.
I was using this function with eregi_replace:
function mak_clickable($string) {
$string = eregi_replace("(([[:alnum:]]+://)|www\.)([^[:space:]]*)([[:alnum:]#?/&=])", "<a href=\"\\1\\3\\4\" target=\"new\">\\1\\3\\4</a>", $string);
$string = eregi_replace("href=\"www","href=\"http://www", $string);
$string = eregi_replace("(([a-z0-9_]|\\-|\\.)+@([^[:space:]]*)([[:alnum:]-]))", "<a href=\"mailto:\\1\" title=\"E-mail \\1\">\\1</a>", $string);
$string = preg_replace("/>(([[:alnum:]]+:\/\/)|www\.)([^[:space:]]{20,30})([^[:space:]]*)([^[:space:]]{10,20})([[:alnum:]#?\/&=])</", ">\\1\\3...\\5\\6<", $string);
return($string);
}
I am looking for a similar function without eregi_replace which does the following:
- Converts all URLs and emails into clickable links.
- Long links makes shorter between > and </a> to prevent page design destroy.
- Converts clickable links back to plain text URLs and emails for text editinging in a form textarea.
I have checked Word Press make_clickable function. It's OK but it does not make long links shorter between > </a> There are also no function how to convert links back to plain text.