Jump to content


Photo

Auto-Link-age


  • Please log in to reply
2 replies to this topic

#1 bcoffin

bcoffin
  • Members
  • PipPipPip
  • Advanced Member
  • 130 posts

Posted 30 March 2006 - 06:45 PM

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
Ben Coffin
bcoffin@hotmail.com

#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 30 March 2006 - 06:49 PM

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]

Info: PHP Manual


#3 bcoffin

bcoffin
  • Members
  • PipPipPip
  • Advanced Member
  • 130 posts

Posted 30 March 2006 - 07:00 PM

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).
Ben Coffin
bcoffin@hotmail.com




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users