打破单词,但不打开标签 [英] Break words, but not tags

查看:66
本文介绍了打破单词,但不打开标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我有从mySQL数据库中提取的数据。我曾经按过这样的文字,比如

这个:

nl2br(wordwrap(htmlentities(stripslashes($ entry [" msg"])),27,"" ,0))


现在我有一个问题:我希望粘贴的链接成为真正的链接。我发现这是一个脚本......

(在这篇帖子的底部)


我有3个问题:

1:脚本无法识别图像链接....(* .jpg,* .gif等...),

我真的我不知道如何解决这个问题...它处理的事情

喜欢''* .php?参数''好吧。


2 :如果我有一个很长的网址,它会扭曲我的布局,所以希望它被打破,但当然不是在标签内部,而只是视觉标签...

我试过wordwrap,但这也打破了我的标签.....


3:我希望视觉部分不显示''http:/ /''部分,但是

当然它必须链接到那个...


希望这不是太多......


Greetz Frizzle



----------------代码------- -----------

函数makeClickableLinks($ text_string)

{

$ text_string =

eregi_replace(''(( (f | ht){1} tp://)[-a-zA-Z0-9 @:%_ \ + .~#?& // =] +)'',''< a

href =" \\1"类= QUOT; bodylink" target =" _blank"> \\1< / a>'',$ text_string);

$ text_string =

eregi_replace(''([[ :space:]()[{}])(www。[ - a-zA-Z0-9 @:%_ \ + .~#?& // =] +)'',

''\\\\< a href =" \\\\" class =" bodylink" target =" _blank"> \\\\< / a>'',

$ text_string);

$ text_string =

eregi_replace(''([_ \ 0-9a-z - ] + @([ 0-9a-z] [0-9a-z - ] + \。)+ [az] {2,3})'',''< a

href =" mailto :\\\\" class =" bodylink"> \\1< / a>'',$ text_string);

返回str_replace(''target =" _blank" > http://'',''target =" _blank">'',

$ text_string);

};

解决方案

entry [" msg"])),27," ",0))


现在我有一个问题:我希望粘贴的链接成为真正的链接。我发现这是一个脚本......

(在这篇帖子的底部)


我有3个问题:

1:脚本无法识别图像链接....(* .jpg,* .gif等...),

我真的我不知道如何解决这个问题...它处理的事情

喜欢''* .php?参数''好吧。


2 :如果我有一个很长的网址,它会扭曲我的布局,所以希望它被打破,但当然不是在标签内部,而只是视觉标签...

我试过wordwrap,但这也打破了我的标签.....


3:我希望视觉部分不显示''http:/ /''部分,但是

当然它必须链接到那个...


希望这不是太多......


Greetz Frizzle



----------------代码------- -----------

函数makeClickableLinks(


text_string)

{

text_string =

eregi_replace(''(((f | ht){1} tp://)[ - a-zA-Z0-9 @:%_ \ + .~# ?& // =] +)'',''< a

href =" \\1"类= QUOT; bodylink"目标= QUOT; _blank"> \\1< / A>,

Hi there,

I have data drawn from a mySQL DB. I used to massage the text like
this:
nl2br(wordwrap(htmlentities(stripslashes($entry["msg"])), 27, " ", 0))

Now i have a problem: i wanted pasted links to become real links. I
found a script to do that...
(on the bottom of this post)

I have 3 problems:
1: The script doesn''t recognise image links.... (*.jpg, *.gif, etc...),
and i really don''t have a clue how to fix this... It handles things
like ''*.php?parameter'' well.

2: if i have a very long url, it distorts my layout, so want it to be
broken, but of course not inside the tag, but only the ''visual'' tag...
I tried wordwrap, but that also breaks my tags.....

3: I want the visual part not to display the ''http://'' part, but of
course it has to link to that...

Hope this is not too much...

Greetz Frizzle


----------------Code------------------

function makeClickableLinks($text_string)
{
$text_string =
eregi_replace(''(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)'', ''<a
href="\\1" class="bodylink" target="_blank">\\1</a>'', $text_string);
$text_string =
eregi_replace(''([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)'',
''\\1<a href="\\2" class="bodylink" target="_blank">\\2</a>'',
$text_string);
$text_string =
eregi_replace(''([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})'', ''<a
href="mailto:\\1" class="bodylink">\\1</a>'', $text_string);
return str_replace('' target="_blank">http://'','' target="_blank">'',
$text_string);
};

解决方案

entry["msg"])), 27, " ", 0))

Now i have a problem: i wanted pasted links to become real links. I
found a script to do that...
(on the bottom of this post)

I have 3 problems:
1: The script doesn''t recognise image links.... (*.jpg, *.gif, etc...),
and i really don''t have a clue how to fix this... It handles things
like ''*.php?parameter'' well.

2: if i have a very long url, it distorts my layout, so want it to be
broken, but of course not inside the tag, but only the ''visual'' tag...
I tried wordwrap, but that also breaks my tags.....

3: I want the visual part not to display the ''http://'' part, but of
course it has to link to that...

Hope this is not too much...

Greetz Frizzle


----------------Code------------------

function makeClickableLinks(


text_string)
{


text_string =
eregi_replace(''(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)'', ''<a
href="\\1" class="bodylink" target="_blank">\\1</a>'',


这篇关于打破单词,但不打开标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆