<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: addresses code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 24 Jul 2008 08:43:14 GMT</pubDate>
    <description>DZone Snippets: addresses code</description>
    <item>
      <title>Make anchors from urls and email addresses</title>
      <link>http://snippets.dzone.com/posts/show/617</link>
      <description>This little PHP function will find urls and email addresses in a block of text and turn them into hyperlinks and mailto: anchors respectively.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;function makeLinks($sourceText) {&lt;br /&gt;  $destText = preg_replace( "/([_a-zA-Z0-9-]+)(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+)(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,4})/", '&lt;a href="mailto:\\0"&gt;\\0&lt;/a&gt;',$sourceText);&lt;br /&gt;  $destText = preg_replace_callback('/\bhttp[^\s]+/',create_function('$matches', 'return "&lt;a href=\"$matches[0]\"&gt;" . preg_replace("#(\.|/)#", "&amp;shy;$1", $matches[0]) . "&lt;/a&gt;";'),$destText);&lt;br /&gt;  return $destText;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 01 Sep 2005 02:44:51 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/617</guid>
      <author>hjalli (Hjalmar Gislason)</author>
    </item>
  </channel>
</rss>
