having an issue with something. I have an array called result which is in the following format:
Array
(
[count] => 74
[0] => Array
(
[15] => usncreated
[memberof] => Array
(
[count] => 3
[0] => GroupA
[1] => GroupB
[2] => GroupC
)
)
[1] => Array
(
[15] => usncreated
[memberof] => Array
(
[count] => 2
[0] => GroupA
[1] => GroupF
)
)
)
I am trying to build up my own array now. At the moment I have
foreach($result as $user) {
if(isset($user["memberof"])){
foreach($user["memberof"] as $group) {
$groups[] = $group;
}
}
$userData["group"] = $groups;
print_r("<pre>");
print_r($userData);
print_r("</pre>");
}
Problem is my output is like so
Array
(
[group] => Array
(
[0] => 2
[1] => GroupA
[2] => GroupB
)
)
Array
(
[group] => Array
(
[0] => 2
[1] => GroupA
[2] => GroupB
[3] => 2
[4] => GroupA
[5] => GroupF
)
)
So the second one repeats the first. If I move the print_r somewhere else, like outside the loop, I just see one user with every possible group. I know it needs to print in a loop, but whatever I try I cant get the correct output.
How can I get it to only display the groups for each user?
Thanks