In the provided PHP code snippet for the BBCode Parser, are there any areas that could be optimized or improved for better performance?

The issue with the provided PHP code snippet for the BBCode Parser is that it uses a loop to replace each BBCode tag with its corresponding HTML tag, which can be inefficient for large strings with multiple BBCode tags. One way to improve performance is to use a regular expression with the `preg_replace` function to replace all BBCode tags in a single pass.

// Improved PHP code snippet for BBCode Parser using regular expressions for better performance

function parseBBCode($text) {
    $bbcode = [
        '/\[b\](.*?)\[\/b\]/is' => '<strong>$1</strong>',
        '/\[i\](.*?)\[\/i\]/is' => '<em>$1</em>',
        '/\[u\](.*?)\[\/u\]/is' => '<u>$1</u>',
        '/\[url\](.*?)\[\/url\]/is' => '<a href="$1">$1</a>'
    ];

    foreach ($bbcode as $pattern => $replacement) {
        $text = preg_replace($pattern, $replacement, $text);
    }

    return $text;
}

// Example usage
$text = "[b]Hello[/b] [i]World[/i]";
echo parseBBCode($text);