0

hey guys i have a bit of a chicken or egg problem. I query an ldap database for a list of users and recieve a 2-dimensional array in the form

Array[index]['username']

The ldap database is currently not sorted alphabetically, or at least records are not being retrieved in an alphabetic order, so using a for loop on the [index] returns an unsorted looking list. How can i sort my Array alphabetically by the values in 'username'? is this even possible(easily)? :O

mannadu
  • 319
  • 3
  • 10

1 Answers1

0

There's loads of duplicates for that... but here you go:

usort($array, function($a,$b){ return strcmp($a['username'], $b['username']); } );
Emissary
  • 9,018
  • 8
  • 50
  • 58
Wrikken
  • 64,168
  • 8
  • 83
  • 130
  • I did search quite a bit before asking. Perhaps the language i was using to search was off.. Many thanks – mannadu Mar 19 '13 at 18:33