Jump to content
php.lv forumi

bbCode


SkaKri

Recommended Posts

function bbcode_format ($str) {


	$simple_search = array( 
	'/\n|(\r\n)/m',
							'/\[b\](.*?)\[\/b\]/is',								
							'/\[i\](.*?)\[\/i\]/is',								
							'/\[u\](.*?)\[\/u\]/is',
							'/\[small\](.*?)\[\/small\]/is',
							'/\[url\=(.*?)\](.*?)\[\/url\]/is'
							);

	$simple_replace = array(
							'<br />',
							'<b>$1</b>',
							'<i>$1</i>',
							'<u>$1</u>',
							'<small>$1</small>',
							'<a href="$1" target="_blank">$2</a>'
							);

	$str = preg_replace ($simple_search, $simple_replace, $str);

	return $str;
}

echo (bbcode_format('teksts [b]johohoo[/b]'));

Link to comment
Share on other sites

×
×
  • Create New...