phpBB2 style Group Legend display

Display group legend on the index like it was in good 'ol phpBB 2!

Requested by princexxx in this topic, this snippet will modify the group legend on the index too look like it did back on phpBB2.

#
#-----[ OPEN ]------------------------------------------
#
index.php
#
#-----[ FIND ]------------------------------------------
#
    $legend = array();
    while ($row = $db->sql_fetchrow($result))
    {
        $colour_text = ($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . '"' : '';
        $group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];

        if ($row['group_name'] == 'BOTS' || ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')))
        {
            $legend[] = '<span' . $colour_text . '>' . $group_name . '</span>';
        }
        else
        {
            $legend[] = '<a' . $colour_text . ' href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']) . '">' . $group_name . '</a>';
        }
    }
    $db->sql_freeresult($result);

    $legend = implode(', ', $legend);  
#
#-----[ REPLACE WITH ]------------------------------------------
#
    $legend = array();
    while ($row = $db->sql_fetchrow($result))
    {
        $colour_text = ($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . '"' : '';
        $group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];

        if ($row['group_name'] == 'BOTS' || ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')))
        {
            $legend[] = '[ <span' . $colour_text . '>' . $group_name . '</span> ]';
        }
        else
        {
            $legend[] = '[ <a' . $colour_text . ' href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']) . '">' . $group_name . '</a> ]';
        }
    }
    $db->sql_freeresult($result);

    $legend = implode(' ', $legend);  

Group legend before

Group legend after

You can easily play about with the separators. The brackets were added to $legend[] and the spacing is done here - $legend = implode(' ', $legend); (that's where I removed the comma from.)