How can PHP BB-Tags be effectively used in the code snippet provided?

To effectively use PHP BB-Tags in the provided code snippet, you can create a function that parses the BB-Tags and converts them into HTML tags. This function can be called whenever you need to display user input that contains BB-Tags. By doing this, you can ensure that the BB-Tags are properly converted and displayed on the website.

function parseBBTags($text) {
    $bbtags = array(
        '[b]' => '<strong>',
        '[/b]' => '</strong>',
        '[i]' => '<em>',
        '[/i]' => '</em>',
        '[u]' => '<u>',
        '[/u]' => '</u>'
    );

    foreach($bbtags as $key => $value) {
        $text = str_replace($key, $value, $text);
    }

    return $text;
}

$userInput = "[b]Hello[/b] [i]World[/i]!";
echo parseBBTags($userInput);