Note that ldap_get_entries return an associative array with the attributes in lower case. So for example the givenName ldap attribute is associated with $ldap[0]["givenname"][0] (for the first given name for the first result) this is a little confusing at first.