How can the highlight function be integrated into a BBCode function in PHP to only highlight the content within specific tags?

To integrate the highlight function into a BBCode function in PHP to only highlight the content within specific tags, you can modify the existing BBCode parsing logic to detect the specific tags that need to be highlighted. Once these tags are identified, you can apply the highlight function to only the content within those tags.

function parseBBCode($text) {
    $text = preg_replace_callback(
        '/\[highlight\](.*?)\[\/highlight\]/s',
        function($matches) {
            return highlight($matches[1]);
        },
        $text
    );

    return $text;
}

function highlight($content) {
    // Implement your highlight logic here
    return '<span style="background-color: yellow;">' . $content . '</span>';
}

// Example usage
$input = '[highlight]This is a highlighted text[/highlight]';
$output = parseBBCode($input);
echo $output;