开发者

link clickable and wordwrap

i'm using php wordwrap for my comment box.

This is my clickable function,

function clickable_link($text)
{
$ret = ' ' . $text;
$ret = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a class=\"hrefLink\" href=\"\\2\" target=\"_blank\">\\2</a>", $ret);
$ret =开发者_StackOverflow社区 preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a class=\"hrefLink\" href=\"http://\\2\" target=\"_blank\">\\2</a>", $ret);
$ret = preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret);
$ret = substr($ret, 1);
return $ret;
} 

and this is my wordwrap for comment

$comment = clickable_link($comment);
$comment = wordwrap($comment, 25, "\n", false);

so, once the word limit for 25 is reached, my comment box break my link

http://www.websitetitle.com/showthread.php?t=2000

link become like this

http://www.websitetitle.com/showthread.php?
<br>
t=2000

The link is broken. so is it possible to fix the link or any other workaround?

Thank you


The wordwrap function is breaking the link.

If you're trying to restrict the width of the comment box then I would suggest you do it within CSS rather than rely on the wordwrap function.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜