mh.. I can try to do my answer
you wrote this:
<?php
foreach($group_membership as $i => $username) {
$items = array($username);
}
print_r($items);
?>
and in your case I do this:
<?php
$items = array();
foreach ($group_membership as $username) { // If you need the pointer (but I don't think) you have to add '$i => ' before $username
$items[] = $username;
} ?>
as you show on your question seems that you need an array of user that are in a group or more group :) In this case I prefer a good sql query with a simple while ;)
<?php
$query = "SELECT `username` FROM group_membership AS gm LEFT JOIN users AS u ON gm.`idUser` = u.`idUser`";
$result = mysql_query($query);
while ($record = mysql_fetch_array($result)) { $items[] = $username; } ?>
'while' is more faster, but the last example is only a result of a observation :)
Have a nice day