All pastes #632807 Raw Edit

Mine

public text v1 · immutable
#632807 ·published 2007-07-25 05:19 UTC
rendered paste body
<?php
$post = '[b]lol[/b]';
function bbcode($string) {
	
$string = str_replace(array('<', '>'), array('&lt;', '&gt;'), $str);
	$match = array(
			'#\[b\](.*?)\[\/b\]#se',
			'#\[i\](.*?)\[\/i\]#se',
			'#\[u\](.*?)\[\/u\]#se',
			'#\[s\](.*?)\[\/s\]#se',
			'#\[url=(.*?)\](.*?)\[\/url\]#se',
			'#\[url](.*?)\[\/url\]#se',
			'#\[email\](.*?)\[\/email\]#se',
			'#\[img](.*?)\[\/img\]#se',
			'#\[img alt=(.*?)](.*?)\[\/img\]#se'
		);
		
		$replace = array(
			"'<strong>\\1</strong>'",
			"'<em>\\1</em>'",
			"'<span style=\"text-decoration: underline;\">\\1</span>'",
			"'<strike>\\1</strike>'",
			"'<a href=\"' . fix_url('\\1') . '\">\\2</a>'",
			"'<a href=\"' . fix_url('\\1') . '\">' . fix_url('\\1') . '</a>'",
			"'<a href=\"mailto:\\1\">\\1</a>'",
			"'<img style=\"border: 0;\" src=\"\\1\" alt=\"BROKEN IMAGE :C\" />'",
			"'<img style=\"border: 0;\" src=\"\\2\" alt=\"\\1\" />'"
		);
		
		$string = preg_replace($match, $replace, $string);
		return $string;
}

$parsedPost = bbcode($post);
echo $parsedPost;
?>