Created
November 3, 2017 09:33
-
-
Save vooxo/238b09837f36c97a23f068029b9509a5 to your computer and use it in GitHub Desktop.
Make readable array from ldap_get_entries() result in PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Convert LDAP resulting array to clean entries array with attributes and values | |
* | |
* @param $resultArray | |
* @return array | |
*/ | |
public function convertLdapResult($resultArray) | |
{ | |
$entries = array(); | |
foreach ($resultArray as $resIdx => $resEntry) { | |
$entry = array(); | |
foreach($resEntry as $enKey => $enVal) { | |
if (is_numeric($enKey)) | |
continue; | |
if($enVal[0]) | |
$entry[$enKey] = $enVal[0]; | |
} | |
if ($entry) | |
$entries[] = $entry; | |
} | |
return $entries; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice, it really beautifies it!