You'd need to parse the .htgroup file directly probably. The
browser can't give you that information, because it doesn't know.
The webserver won't set it, because the same user may be in several
different groups.
Maybe you could describe exactly what you need the script
to do overall; there may be a better way of going about setting
up your .htaccess structure so that you may not even need the
script to know the group.