-2

Here is my out put array:

Array
(
    [count] => 1
    [0] => Array
        (
            [cn] => Array
                (
                    [count] => 1
                    [0] => Testgroep
                )

            [0] => cn
            [member] => Array
                (
                    [count] => 5
                    [0] => CN=Hans Hansen,OU=Test,DC=stefan,DC=nl
                    [1] => CN=Jaap Jaapen,OU=Test,DC=stefan,DC=nl
                    [2] => CN=Peter Petersen,OU=Test,DC=stefan,DC=nl
                    [3] => CN=Piet Pietersen,OU=Test,DC=stefan,DC=nl
                    [4] => CN=Administrator,CN=Users,DC=stefan,DC=nl
                )

            [1] => member
            [distinguishedname] => Array
                (
                    [count] => 1
                    [0] => CN=Testgroep,OU=Test,DC=stefan,DC=nl
                )

            [2] => distinguishedname
            [samaccountname] => Array
                (
                    [count] => 1
                    [0] => Testgroep
                )

            [3] => samaccountname
            [objectcategory] => Array
                (
                    [count] => 1
                    [0] => CN=Group,CN=Schema,CN=Configuration,DC=stefan,DC=nl
                )

            [4] => objectcategory
            [count] => 5
            [dn] => CN=Testgroep,OU=Test,DC=stefan,DC=nl
        )

)

And this is the php code for the array:

$result = $adldap->group()->info('Testgroep');

Now I want to check if the value "OU=Test" exists in the [1] => member part of the array. How can I achieve this? I googled and searched on stackoverflow but don't came up with a solution. Your help is welcome.

Phylogenesis
  • 7,775
  • 19
  • 27
Stefan
  • 5
  • 7
  • take a look at http://stackoverflow.com/questions/12315536/search-for-php-array-element-containing-string – VF_ Apr 29 '14 at 09:38
  • Are you looking for whether any group members are in that OU, or a list of those that are, or something else entirely? – Phylogenesis Apr 29 '14 at 09:41
  • No I want to check the value "OU=Test" if it's present in that piece of the array. – Stefan Apr 29 '14 at 09:42
  • I assume you're actually talking about the `[distinguishedname]` part of the array, then. The integer keys are just there to enumerate the text keys. If you look closely `[1] => member` has no children, it's the `[distinguishedname]` key that does. – Phylogenesis Apr 29 '14 at 10:37

1 Answers1

0

try this code

if(strpos($result[0]['distinguishedname'][0], 'OU=Test') !== false) {
    //yep!
}

and if this not help you at all, please update your question and add more details, so we can understand.

cheers!

Gian Carlo
  • 215
  • 2
  • 6