I have a multi-dimensional array that contains lists (arrays) of userids that belong to a given group. For example:
Code: Select all
$useridsїgreen]ї0]=joe
$useridsїgreen]ї1]=sam
$useridsїgreen]ї2]=jim
$useridsїred]ї0]=joe
$useridsїblue]ї0]=joe
$useridsїblue]ї1]=jane
What I'm trying to do is compute the intersection of the individual arrays making up the larger, mult-dimensional array. In the sample above, the result would be joe, as joe is the only userid in the green, red, and blue groups. The multi-dimensional array is loaded by taking a set of groups checked by a user on a form and querying an LDAP server to get the members of the individual checked groups. If I can figure out this array intersection piece, I'll have a form that allows and administrator to check some groups on a form and produce a list of userids that are members of ALL the groups that were checked.
I've tried various incarnations of foreach loops and the array_intersect, array_values, and array_keys functions. At this point, I can verify that the LDAP query is loading the array correctly by using nested foreach loops to print the members of all the groups checked on the form.
However, the logic here is kicking me in the head and I'm starting to get dizzy.
Thanks in advance for saving my head.