Likes: 0
Results 1 to 1 of 1
Thread: [PHP] BBCode System
-
02-03-10, 12:32 AM #1
[PHP] BBCode System
Register to remove this adMaverfax told me to make one, so I did.
PHP Code:<?php
/*************************************************
/* *
/* Author: Adam Višarsson *
/* Project: Learning PHP 8) *
/* *
/* bbcode.php - BBCode system. *
/* *
/************************************************/
function bbcode($text) {
$text = strip_tags($text, '<br />');
$search = array('/\[b\](.*?)\[\/b\]/i',
'/\[i\](.*?)\[\/i\]/i',
'/\[u\](.*?)\[\/u\]/i',
'/\[url=(.*?)\](.*?)\[\/url\]/i',
'/\[code\](.*?)\[\/code\]/i',
'/\[img\](.*?)\[\/img\]/i',
'/\:D/i',
'/\:P/i',
'/\:\)/i',
'/\:\(/i',);
$h_toda_tml = array('<strong>$1</strong>',
'<i>$1</i>',
'<u>$1</u>',
'<a href="$1">$2</a>',
'<code>$1</code>',
'<img src="$1" alt="image" />',
'<img src="http://septimuswow.com/forums/public/style_emoticons/default/biggrin.gif" alt="grin" />',
'<img src="http://septimuswow.com/forums/public/style_emoticons/default/tongue.gif" alt="tongue" />',
'<img src="http://septimuswow.com/forums/public/style_emoticons/default/smile.gif" alt="smile" />',
'<img src="http://septimuswow.com/forums/public/style_emoticons/default/sad.gif" alt="sad" />',);
$text = preg_replace($search, $h_toda_tml, $text);
return $text;
}
?>
How to install this?
First of all your page must include the page/script holding the bbcode system, if you save the above code as bbcode.php, you can include it like this:
PHP Code:<?php include('bbcode.php');?>
To make stuff display using the BBcode system in the right BBcodes, you need to echo it by doing this:
PHP Code:<?php echo bbcode('Hello guise, this text is [B]Bold[/B]! And this is [U]Underlined[/U]');?>
Hello guise, this text is Bold! And this is Underlined
- CREDITS TO Pingue 8)
› See More: [PHP] BBCode System
Related Threads - Scroll Down after related threads if you are only interested to view replies for above post/thread
Visitors found this page by searching for:
Nobody landed on this page from a search engine, yet!
SEO Blog