arg, sort the results of an LDAP search
| From: | Angus Mackay | Date: | Wed, 26 Jul 2000 19:58:54 +0000 |
| Subject: | arg, sort the results of an LDAP search | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-8392@lists.php.net to get a copy of this message | ||
I have banged my head into a wall long enough with this. I need to sort the
results of an ldap_search via my own method (givenname . sn instead of the
default uid).
anyway everything I have tried does not work.
here is the code that I think should work:
$sr=ldap_search($ds, $dn, $filter, $justthese);
if(!$sr) { return; }
$info = ldap_get_entries($ds, $sr);
function cmp($a, $b)
{
if(!is_array($a) || !is_array($b))
{
return(-1);
}
$A = $a['givenname'][0] . $a['sn'][0];
$B = $b['givenname'][0] . $b['sn'][0];
echo "A: ", $A, "\n";
echo "B: ", $B, "\n";
return(strcmp($A, $B));
}
uasort($info, cmp);
this doesn't change $info at all though. it does print out all the right A:, B: comparisons
though.
I am sure that someone has to have wanted to sort the results of an ldap search before. please help!
cheers, Angus.