Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function formatPost( $text ) {
- // BBcode array
- $find = array(
- '~\[center\](.*?)\[/center\]~si',
- '~\[right\](.*?)\[/right\]~si',
- '~\[b\](.*?)\[/b\]~si',
- '~\[i\](.*?)\[/i\]~si',
- '~\[u\](.*?)\[/u\]~si',
- '~\[quote\](.*?)\[/quote\]~si',
- '~\[size=(.*?)\](.*?)\[/size\]~si',
- '~\[color=(.*?)\](.*?)\[/color\]~si',
- '~\[url\]((?:ftp|https?)://.*?)\[/url\]~si',
- '~\[img\](https?://.*?\.(?:jpg|jpeg|gif|png|bmp))\[/img\]~si'
- );
- // HTML tags to replace BBcode
- $replace = array(
- '<center>$1</center>',
- '<span style="float:right">$1</span>',
- '<b>$1</b>',
- '<i>$1</i>',
- '<span style="text-decoration:underline;">$1</span>',
- '<pre>$1</'.'pre>',
- '<span style="font-size:$1px;">$2</span>',
- '<span style="color:$1;">$2</span>',
- '<a href="$1">$1</a>',
- '<img src="$1" alt="" />'
- );
- // Replacing the BBcodes with corresponding HTML tags
- return nl2br(preg_replace($find,$replace,$text));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement