SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru
    Join Date
    Mar 2004
    Posts
    639
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need an idea about how to convert bbcode to smilies, images etc

    Hello guys,

    I need an idea about how to convert codes like:

    Code:
    ;) :smile2: :lol: :) [b] [/img] [url = http://www.site.com/file.html] [i] [quote] etc
    Of course, I can get one symbol from string and check if it's ":" or ";" or "[" and then convert them to some HTML. Or I can get all codes to an array and replace all know codes to HTML, but then I will not be able to convert codes like:

    Code:
    [url = http://www.site.com/file.html]Link title[/url] or [img]282[/img]
    I wonder, is there any "smart" way to do it? Also, maybe there is some built-in PHP function or some PECL/PHP classes?

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    After some googling, I found this:
    http://corz.org/blog/inc/cbparser.php
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  3. #3
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if you use smarty for templates take a look at this
    http://smarty.incutio.com/?page=BBCodePlugin

    even if you don't use it you may extract function and use it in your app.

  4. #4
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •