tags:

views:

32

answers:

1

I need help optimizing the code to run faster, unless it is optimized the best.

I also want to alphabetize the list and I am unsure how to do that.

It should be alphabetized by $userinfo[0]["sn"][0]

I am using the adLDAP class: http://adldap.sourceforge.net/

<?php

require_once('adLDAP.php');
//header('Content-type: text/json');
$adldap = new adLDAP();

$groupMembers = $adldap->group_members('STAFF');

//print_r($groupMembers);

$userinfo = $adldap->user_info($username, array("givenname","sn","telephonenumber"));
$displayname = $userinfo[0]["givenname"][0]." ".$userinfo[0]["sn"][0];
print "<ul>";
foreach ($groupMembers as $i => $username) {
  $userinfo = $adldap->user_info($username, array("*"));
  $displayname = "<strong>".$userinfo[0]["givenname"][0]." ".$userinfo[0]["sn"][0]."</strong> - ".$userinfo[0]["telephonenumber"][0];
  if($userinfo[0]["sn"][0] != "" && $userinfo[0]["givenname"][0] != "" && $userinfo[0]["telephonenumber"][0] != "") {
    print "<li>".$displayname."</li>";
  }
}
print "</ul>";
?>
+1  A: 

I dont know about optmizing but to order your array you can use an example on PHP help page called multi_sort: link text

There is a comment regarding code injection on the example provided but you can workaround that I think.

Ronaldo Junior
as simple as sort($groupMembers);thank you.
Brad