Posted By

Shpigford on 11/24/06


Tagged

bbcode


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

vali29
skywalker
Kerrick


BBCode


 / Published in: PHP
 

  1. function bbcode_format($var) {
  2. $search = array(
  3. '/\[b\](.*?)\[\/b\]/is',
  4. '/\[i\](.*?)\[\/i\]/is',
  5. '/\[u\](.*?)\[\/u\]/is',
  6. '/\[img\](.*?)\[\/img\]/is',
  7. '/\[url\](.*?)\[\/url\]/is',
  8. '/\[url\=(.*?)\](.*?)\[\/url\]/is'
  9. );
  10.  
  11. $replace = array(
  12. '<strong>$1</strong>',
  13. '<em>$1</em>',
  14. '<u>$1</u>',
  15. '<img src="$1" />',
  16. '<a href="$1">$1</a>',
  17. '<a href="$1">$2</a>'
  18. );
  19.  
  20. $var = preg_replace ($search, $replace, $var);
  21.  
  22. return $var;
  23. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: patty08 on April 3, 2008

Can anyone add list to the above code ? Bullets, numbers or letters please cause I do not get how to do it.

You need to login to post a comment.