10-25-2007, 08:30 AM
|
#5 (permalink)
|
|
Super Moderator
Join Date: Sep 2007
Posts: 165
Thanks: 0
|
You do need to be able to understand preg pattern matching to be able to understand this, but something like:
PHP Code:
function BBParser($szInput) {
$aBBPattern = array( '[b](.*?)[/b]' => '<b>\\1</b>', '[i](.*?)[/i]' => '<i>\\1</i>', '[url=([^\]+?)](.*?)[/url]' => '<a href="\\1">\\2</a>' );
foreach( $aBBPattern as $szKey => $szValue ) { $szPattern = '/'. preg_quote( $szKey, '/' ) .'/is'; $szInput = preg_replace( $szPattern, $szValue, $szInput ); }
return $szInput;
}
Remember this isnt tested, but the theory is there :)
|
|
|
|