Please find attached a screenshot of the problem that I am experiencing.

I would like to echo out the value of cn from my multidimensional array. My array for exmaple is called $information. I am attempting to echo the value of cn by doing this:
echo "$information['cn'][0]";. I have also tried $information['cn'][0] and $information["cn"][0] however I keep getting the error undefined index.

When I attempt to loop through the array using a foreach I do not receive an out of the array.

Could some one please shed some light on why I am not able to echo the common name i.e. cn.

Thank You

    'undefined index' errors occur when you try to access an element of an index that you never bothered to set in the first place. Sadly, there is tons of code out there that makes this mistake.

      Guys thank you for your replies.

      The values that can be seen in the multi-dimensional array were extracted from Active Directory. According tot he array the cn the user is Charlie Chaplin.

      From that I thought that the index (i.e. ['cn']) contained a value and that value was Charlie Chaplin?.

      Please excuse me for asking, is there a way to get hold of the comman name from the array?.

      I am not sure if this helpful or not but the code for searching and extracting Active Directory data is as follows:

      $searched = ldap_search($connectiontoad, $dn, $filter, $arrayofadattributes);

      $information = ldap_get_enteries($connectiontoad, $searched);

      I had put a print_r($information statement) here. The output is shown in the screenshot, of my first post.

      Thank You

        You have an array of an array of an array (3 array levels) so you would need 3 brackets to access the bottom level

        echo $my_array[index1][index2][index3]

          Thank you very much to every one for your help.

          Now I get on with the remaining parts of the program.

            Write a Reply...