<?php
function forumbbcode($text) {
if(preg_match("/\[/", $text)) {
$match = array(
'/\[b\](.+?)\[\/b\]/is',
'/\[u\](.+?)\[\/u\]/is',
'/\[i\](.+?)\[\/i\]/is',
'/\[url=(.+?)\](.+?)\[\/url\]/is',
'/\[url\](.+?)\[\/url\]/is',
'/\[quote\](.+?)\[\/quote\]/is'
);
$replace = array(
'<b>$1</b>',
'<u>$1</u>',
'<i>$1</i>',
'<a href="$1">$2</a>',
'<a href="$1">$1</a>',
'<div class="quote">$1</div>'
);
return preg_replace($match, $replace, $text);
}
}
?>
I have this kind of BBCode parser, but only problem is that it doesn't allow for ex. multiple quotes inside.
if i put
[quote]asd[quote]efg[/quote][/quote]
it will return
<div class="quote">asd[quote]efg[/quote]</div>