Jump to content

Archived

This topic is now archived and is closed to further replies.

bcoffin

Auto-Link-age

Recommended Posts

Could somebody please recommend a good way to input a textarea's contents and return the same contents, whereas all patterns matching a URL or EMAIL address are auto-linked?

ie:

Aliquam posuere iaculis [!--coloro:#CC6600--][span style=\"color:#CC6600\"][!--/coloro--]www.augue.com[!--colorc--][/span][!--/colorc--]. Mauris dictum pellentesque ipsum. Nam lacus. Sed mattis commodo lectus. Duis malesuada, lorem et gravida mattis, magna purus viverra orci, id tempus ante lorem et arcu. Nullam congue orci at metus. Ut tortor pede, placerat a, tristique eget, tempor id, augue. Mauris tincidunt risus sit amet diam. Mauris vehicula lectus eu dui. Aenean porttitor gravida purus. Vivamus nisl ipsum, aliquam sed, tincidunt vitae, dictum quis, purus. [!--coloro:#CC6600--][span style=\"color:#CC6600\"][!--/coloro--]Nam@bibendum.com [!--colorc--][/span][!--/colorc--]diam.

becomes

Aliquam posuere iaculis [!--coloro:#CC6600--][span style=\"color:#CC6600\"][!--/coloro--]<a href='www.augue.com' target='_new'>www.augue.com</a>[!--colorc--][/span][!--/colorc--]. Mauris dictum pellentesque ipsum. Nam lacus. Sed mattis commodo lectus. Duis malesuada, lorem et gravida mattis, magna purus viverra orci, id tempus ante lorem et arcu. Nullam congue orci at metus. Ut tortor pede, placerat a, tristique eget, tempor id, augue. Mauris tincidunt risus sit amet diam. Mauris vehicula lectus eu dui. Aenean porttitor gravida purus. Vivamus nisl ipsum, aliquam sed, tincidunt vitae, dictum quis, purus. [!--coloro:#CC6600--][span style=\"color:#CC6600\"][!--/coloro--]<a href='mailto:Nam@bibendum.com'>Nam@bibendum.com</a>[!--colorc--][/span][!--/colorc--] diam.

THANKS for your help, you guys,

Benny

Share this post


Link to post
Share on other sites
You're going to want to use preg_replace(). If you don't know how to use regular expressions, check out this site: [a href=\"http://www.regular-expressions.info/\" target=\"_blank\"]http://www.regular-expressions.info/[/a]

Share this post


Link to post
Share on other sites
I found this [a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=89136&hl=\" target=\"_blank\"]thread[/a], but the regex_build_url function isn't recognized. (And it doesn't address the email part).

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.