Skip to content

Instantly share code, notes, and snippets.

@vooxo
Created November 3, 2017 09:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vooxo/238b09837f36c97a23f068029b9509a5 to your computer and use it in GitHub Desktop.
Save vooxo/238b09837f36c97a23f068029b9509a5 to your computer and use it in GitHub Desktop.
Make readable array from ldap_get_entries() result in PHP
/**
* 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;
}
@JasonEverling
Copy link

nice, it really beautifies it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment