这是我的数组来自foreach
循环:
Array
(
[count] => 1
[0] => Array
(
[distinguishedname] => Array
(
[count] => 1
[0] => CN=Administratie,OU=Test,DC=stefan,DC=nl
)
[0] => distinguishedname
[count] => 1
[dn] => CN=Administratie,OU=Test,DC=stefan,DC=nl
)
)
Array
(
[count] => 1
[0] => Array
(
[distinguishedname] => Array
(
[count] => 1
[0] => CN=Anderemailgroep,OU=Test,DC=stefan,DC=nl
)
[0] => distinguishedname
[count] => 1
[dn] => CN=Anderemailgroep,OU=Test,DC=stefan,DC=nl
)
)
Array
(
[count] => 1
[0] => Array
(
[distinguishedname] => Array
(
[count] => 1
[0] => CN=Beheergroep,OU=Test,DC=stefan,DC=nl
)
[0] => distinguishedname
[count] => 1
[dn] => CN=Beheergroep,OU=Test,DC=stefan,DC=nl
)
)
Array
(
[count] => 1
[0] => Array
(
[distinguishedname] => Array
(
[count] => 1
[0] => CN=Belangrijke Groep,OU=Test,DC=stefan,DC=nl
)
[0] => distinguishedname
[count] => 1
[dn] => CN=Belangrijke Groep,OU=Test,DC=stefan,DC=nl
)
)
Array
(
[count] => 1
[0] => Array
(
[distinguishedname] => Array
(
[count] => 1
[0] => CN=Hoofdgroep,OU=Test,DC=stefan,DC=nl
)
[0] => distinguishedname
[count] => 1
[dn] => CN=Hoofdgroep,OU=Test,DC=stefan,DC=nl
)
)
Array
(
[count] => 1
[0] => Array
(
[distinguishedname] => Array
(
[count] => 1
[0] => CN=Mailgroep,OU=Test,DC=stefan,DC=nl
)
[0] => distinguishedname
[count] => 1
[dn] => CN=Mailgroep,OU=Test,DC=stefan,DC=nl
)
)
Array
(
[count] => 1
[0] => Array
(
[distinguishedname] => Array
(
[count] => 1
[0] => CN=Testgroep2,OU=Test,DC=stefan,DC=nl
)
[0] => distinguishedname
[count] => 1
[dn] => CN=Testgroep2,OU=Test,DC=stefan,DC=nl
)
)
问题是,如何从列表中的所有数组中获取所有CN = " GroupName" 值?它只需从每个数组中获取该值并将其显示在列表中。
例如:
我只希望每个数组都有这个值。
输出应该是这样的:
Administratie
Anderemailgroep
Beheergroep
Belangrijke Groep
Hoofdgroep
Mailgroep
Testgroep2
修改
阵列来自这段代码:
$result = $adldap->user()->groups('test.user');
for ($i=0;$i<count($result);$i++) {
sort($result);
}
print_r($result);
foreach ($result as $key => $value) {
$check = $adldap->group()->info($value, array(
'distinguishedname'
));
if (strpos($check[0]['distinguishedname'][0], 'OU=Test') !== false) {
unset($result[$key]);
print_r($check);
}
}
答案 0 :(得分:0)
假设您的数组是 $ arrs ,其中包含您提供的数组值。 你可以这样做。
<?php
foreach($arrs as $arr) {
foreach($arr as $ar) {
$sep = explode(',',$ar['dn']);
echo explode('=',$sep[0])[1];
}
}
?>