daily pastebin goal
86%
SHARE
TWEET

bbcode

a guest Mar 1st, 2016 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function BBCode($string){
  2.     $patterns = array(
  3.         '`\*\*(.+?)\*\*`is',
  4.         '`\*(.+?)\*`is',
  5.         '`%%(.+?)%%`is',
  6.         '`\[b\](.+?)\[/b\]`is',
  7.         '`\[i\](.+?)\[/i\]`is',
  8.         '`\[u\](.+?)\[/u\]`is',
  9.         '`\[s\](.+?)\[/s\]`is',
  10.         '`\[spoiler\](.+?)\[/spoiler\]`is',
  11.         '`\[lination\](.+?)\[/lination\]`is',
  12.         );
  13.     $replaces =  array(
  14.         '<b>\\1</b>',
  15.         '<i>\\1</i>',
  16.         '<span class="spoiler">\\1</span>',
  17.         '<b>\\1</b>',
  18.         '<i>\\1</i>',
  19.         '<span style="border-bottom: 1px solid">\\1</span>',
  20.         '<strike>\\1</strike>',
  21.         '<span class="spoiler">\\1</span>',
  22.         '<span style="color: #D14836; border-bottom: 1px dashed #D14836;">\\1</span>',
  23.         );
  24.     $string = preg_replace($patterns, $replaces , $string);
  25.     $string = preg_replace_callback('`\[code\](.+?)\[/code\]`is', array(&$this, 'code_callback'), $string);
  26.    
  27.     return $string;
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top