[PHP] array problem!

Heres my code:


function getGroup() {
$file=fopen(".groups","a+");
for($i=0;$line=fgets($file,200);$i++) {
	 $lineArr=explode(":",$line);
	 $lineArr2=explode(" ",$line);
	 if($lineArr[0]!="") {
$groups[$i][0]=$lineArr[0];
	 }
	 if($lineArr2[1]!="") {
	 $z++;
	 $groups[$i][1]=$lineArr[1];
}
}
fclose($file);
// sort groups by name
@array_multisort($groups);
return $groups;
}
function getGroupUsers() {
$file=fopen(".groups","a+");
$users = array();
$i=0;
while($line=fgets($file,200)) {
	 $line = trim($line);
	 $lineArr=explode(":",$line);
	 $lineArr2 = explode(" ",$lineArr[1]);
	 $lineArr2 = array_filter($lineArr2);
	 $users[$i]=$lineArr2;
	 $i++;
}
fclose($file);
echo "<pre>";
print_r($users);
echo "</pre>";
// sort users by name
@array_multisort($users);
return $users;
}
$groups = getGroup();
$users = getGroupUsers();
if(!empty($groups)) {
echo "<table border=1><tr><td><b>Group Name:<b></td><td><b>User in group</b></td><td>Function</td></tr>";
foreach($groups as $key => $value)
{
echo "<tr><td><font color=red>".$value[0].":</b></font></td>";
echo "<td><select>";
foreach ($users as $key) {
foreach ($key as $value) {
echo "<option>";
echo $value;
echo "</option>";
}
 
}
echo "</select></td>";
echo "<td><input type=\"submit\" value=\"Remove\"></td></tr>";
}

if you gonna test the script creat a file called .groups and put in text in this format…

 
admin: mister test ulla erik stina 
admin2: oskar mister marie anna
admin3: mister erik steve
admin44: fredrik mister ulla
ytter: mister erik master kurt 

The ting I want is to list each user who belongs to that group. I can creat the array correctly see the printout (print_r($users):wink: from function function getGroupUsers

But i can’t figureout HOW to then user forech in a correct way and list first all Groupname and after that in a select menu list all users who belongs to the group!!!

I hope this isn’t hard for you to solve :puzzled: :slight_smile: Pleas ask if you dont get me …

Best regards Marcus aka Mister