|
Posted by bob.chatman@gmail.com on 01/29/07 21:13
On Jan 29, 7:25 am, "benb" <b...@nospam.postalias> wrote:
> Hi
> I've performed a query on Active Directory to pull usernames & mobile
> numbers, using:
>
> <snip>
> $read = ldap_search($connect, $base_dn, $filter, $inforequired)
> $info = ldap_get_entries($connect, $read);
>
> This has returned an array (not sure of the type, is it multidimensional, or
> an array of arrays?) with 2 values:
>
> $info[$i]["displayname"][0]
> and
> $info[$i]["mobile"][0]
>
> When I print this information in a table I get the following
>
> John Doe 077654321
> Joe Blogs 071234567
> Alan Smith 077711223
> ...etc
>
> How do I go about sorting this array, so that [displayname] is alphabetical?
> I've tried using sort($info) but this seems to wipe the array, I've also
> tried sort($info[0]["displayname"]) but that doesn't seem to sort anything!
>
> Any help, or suggestions much appreciated!
>
> Ben
Sort treats the array as though it doesnt have keys. The keys and
values are mixed together and will become one giant array of =P
if you want to sort the keys alphabetically you should use ksort()
http://us2.php.net/manual/en/function.ksort.php
and if you would like to make your own sort algorthm you can use
usort()
http://us2.php.net/manual/en/function.usort.php
[Back to original message]
|