2014-04-30 89 views
-1

值。這是我的數組是從一個foreach循環來:獲得來自多個arrrays

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 = 「組名」值一個列表或什麼?它只需要從每個數組中獲取該值並將其顯示在列表中。

例如:

我只想從每個數組中獲得這個值。

enter image description here

和輸出應該是這樣的:

Administratie 
Anderemailgroep 
Beheergroep 
Belangrijke Groep 
Hoofdgroep 
Mailgroep 
Testgroep2 

EDIT

陣列被從這段代碼來:

$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); 
     } 
    } 
+1

這是一個單一的數組? –

+1

你真的應該開始多想一點自己..考慮這是你的第3篇文章,它總是在你提供的另一段代碼之後.. – Naruto

+1

我們缺少信息。沒有提供代碼示例...這件事本身可以很容易地完成... – thedom

回答

0

比方說你的陣列是$ arrs其中包含給定的數組值。 你可以這樣做。

<?php 

foreach($arrs as $arr) { 
    foreach($arr as $ar) { 
     $sep = explode(',',$ar['dn']); 
     echo explode('=',$sep[0])[1]; 
    } 
} 

?>