I have the following code to create list tags (much like this forum):

PHP Code:
function listtag($text) {
    
$lststyle 'style="margin-top: 0px; margin-bottom: 0px;"';

    if (
preg_match_all('/\[list=(.*)\](.*)\[\/list\]/siU'$text$match)) {
        
$return preg_replace('/<br \/>/'''$match[0]);

        
$text str_replace($match[0], $return$text);
    }

    
$list_tags = array('/\[list=3\](.*)\[\/list\](\r\n|)/siU''/\[\*\](.*)\[\/\*\]/isU');
    
$list_html = array('<ul ' $lststyle '>\\1</ul>''<li>\\1</li>');

    
$text preg_replace($list_tags$list_html$text);
    
$text str_replace("</ul><br />"'</ul>'$text);

    return 
$text;

It works great, except for when there are nested tags, it doesn't seem to grab the inner list tags. Any ideas on how to fix this?