For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > March 2006 > multidim array sort









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author multidim array sort
Abhi

2006-03-12, 6:56 pm

Hi!

I am wondering if someone can point me to the needed sort function. There are so many of
them that I simply got lost by reading their descriptions. I try to explain what I need.

I have a multidimensional array and I have a function that outputs it as a table.

$arr[0] contains an array that contains usernames
$arr[1] contains an array that contains real names
$arr[2] contains an array that contains e-mails
etc...
$arr[last] contains integers for users "levels"

My function outputs users with their datas in the columns. Each column means one user.

Now I want to sort this whole array by levels. So, all other data should be sorted
according to the pattern in levels row.

How is this thing done?

Please advice!


Abhi


Johannes Wienke

2006-03-14, 7:55 am

Am 13.03.2006 01:13 schrieb Abhi:
> Hi!
>
> I am wondering if someone can point me to the needed sort function. There are so many of
> them that I simply got lost by reading their descriptions. I try to explain what I need.
>
> I have a multidimensional array and I have a function that outputs it as a table.
>
> $arr[0] contains an array that contains usernames
> $arr[1] contains an array that contains real names
> $arr[2] contains an array that contains e-mails
> etc...
> $arr[last] contains integers for users "levels"


I'm wondering why to use such a silly construction. It would me much
easier if you do it like this:

$array['useridorsthelse'] = array('name' => 'foobar', 'email' => 'blaa'...)

> My function outputs users with their datas in the columns. Each column means one user.
>
> Now I want to sort this whole array by levels. So, all other data should be sorted
> according to the pattern in levels row.


I think you should change your structure like I explained. The it should
be much easier to sort.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com