I have a multidimensional associative array. I need to loop through the array and put one value through another function that returns a Boolean that will be the value of another member in the array. See below.
The multidimensional array:
$grouparray = array(
"428995" => array(
"group" => "Meetings In Camera - Read",
"access" => false
),
"896325" => array(
"group" => "Meetings In Camera - Modify",
"access" => false
),
"485563" => array(
"group" => "Security Meetings - Modify",
"access" => false
),
"556321" => array(
"group" => "TAC Meetings - Modify",
"access" => false
),
"658823" => array(
"group" => "Restricted Meeting - Modify",
"access" => false
),
"985465" => array(
"group" => "Admin Meetings - Modify",
"access" => false
),
);
I have a function that queries the ldap and returns true or false. I tried nested for loops but the access values are not being changed. However, if I run them individually it works as expected.
This works (But then have to do for each item in array):
checkGroupMembership($ldap, $user, $grouparray[428995]['group']);
However, this does not work
function groupSearch($ldapconn, $user, $grouparray) {
foreach ($grouparray as $key => $value) {
foreach ($value as $sub_key => $sub_value) {
$grouparray[$sub_value][access] = checkGroupMembership($ldap, $user, $grouparray[$sub_value]['group]); // this returns true or false
}
}
}
So basically I want to loop through array use 'group' as an input to another function that returns a Boolean to 'access'