$user = posix_getpwuid(posix_getuid()); // get current user $groups = posix_getgroups(); // get groups for user foreach($groups as $group) { echo posix_getgrgid($group)["name"] . "\n"; // print group name }In this example, `posix_getpwuid()` is used to get information about the current user, and `posix_getgroups()` retrieves the group IDs that the user belongs to. The `foreach` loop then retrieves the name of each group using `posix_getgrgid()`. This function is part of the POSIX extension in PHP, which is included by default in Unix-based operating systems.