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

Manny Adumbire
  • 366
  • 4
  • 11

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,954
  • 8
  • 54
  • 65
Wrikken
  • 69,272
  • 8
  • 97
  • 136