<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: Ichigo's Code Snippets</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 21 Aug 2008 07:38:31 GMT</pubDate>
    <description>DZone Snippets: Ichigo's Code Snippets</description>
    <item>
      <title>ubbcode</title>
      <link>http://snippets.dzone.com/posts/show/109</link>
      <description>a function to convert common used bbcode tags to html... as usually used in message boards and some blog software.&lt;br /&gt;&lt;br /&gt;it handles img, email, link, b, u and i tags...&lt;br /&gt;&lt;br /&gt;for example&lt;br /&gt;&lt;code&gt;&lt;br /&gt;[b]test[/b]&lt;br /&gt;[url=http://blah.com]blah[/url]&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;will become:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;strong&gt;test&lt;/strong&gt;&lt;br /&gt;&lt;a href="http://blah.com" target="_blank"&gt;blah&lt;/a&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;function ubbcode($posting) {&lt;br /&gt;	$posting=eregi_replace("\[img\]([^\[]+)\[/img\]","&lt;img src=\"\\1\" border=\"0\"&gt;",$posting);&lt;br /&gt;	$posting=eregi_replace("\[email\]([^\[]+)\[/email\]","&lt;a href=\"mailto:\\1\"&gt;\\1&lt;/a&gt;",$posting);&lt;br /&gt;	$posting=eregi_replace("\[email=([^\[]+)\]([^\[]+)\[/email\]","&lt;a href=\"mailto:\\1\"&gt;\\2&lt;/a&gt;",$posting);&lt;br /&gt;	$posting=eregi_replace("\[url=([^\[]+)\]([^\[]+)\[/url\]","&lt;a href=\"\\1\" target=\"_blank\"&gt;\\2&lt;/a&gt;",$posting);&lt;br /&gt;	$posting=eregi_replace("\[url\]([^\[]+)\[/url\]","&lt;a href=\"\\1\" target=\"_blank\"&gt;\\1&lt;/a&gt;",$posting);&lt;br /&gt;    $posting=eregi_replace("\[b\]","&lt;strong&gt;",$posting);&lt;br /&gt;    $posting=eregi_replace("\[/b\]","&lt;/strong&gt;",$posting);&lt;br /&gt;    $posting=eregi_replace("\[u\]","&lt;u&gt;",$posting);&lt;br /&gt;    $posting=eregi_replace("\[/u\]","&lt;/u&gt;",$posting);&lt;br /&gt;    $posting=eregi_replace("\[i\]","&lt;em&gt;",$posting);&lt;br /&gt;    $posting=eregi_replace("\[/i\]","&lt;/em&gt;",$posting);&lt;br /&gt;&lt;br /&gt;    return $posting;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 10 Apr 2005 02:21:38 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/109</guid>
      <author>ichigo ()</author>
    </item>
  </channel>
</rss>
