a href problem
| From: | Anders Henke | Date: | Fri, 29 Mar 2002 12:10:44 +0000 |
| Subject: | a href problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-90659@lists.php.net to get a copy of this message | ||
Hi folks!
Im running this forum for Flash users and I have created it in Flash. Now,
I've got this little problem... If a users writes a URL like
http://www.test.com, the url becomes clickable thanks to the code
below.
$text = str_replace("<", "<", $text);
$text = str_replace(">", ">", $text);
$text = str_replace("www.", "http://www.",
$text);
$text = str_replace("http://http://", "http://", $text);
$text = eregi_replace("([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])",
"<u><a href=\"\\1://\\2\\3\"
target=\"_blank\">\\1://\\2\\3</a></u>",
$text);
$text =
eregi_replace("(([a-z0-9_]|\\-|\\.)+@([^[:space:]]*)([[:alnum:]-]))", "<u><a
href=\"mailto:\\1\">\\1</a></u>",
$text);
$text = urlencode($text);
Everything works just fine, until someone writes <a
href="http://www.test.com">http://www.test.com</a>. The
output then becomes
<a href="<a href="http://www.test.com"
target="_blank">http://www.test.com</a>
target="_blank">http://www.test.com</a>.
Does anyone have a solution for this?
Regards
Anders Henke