Welcome Guest, Not a member yet? Register   Sign In
sorting multi multi multidimensional arrays?
#1

[eluser]rogierb[/eluser]
ok, I might have complicated things by using multidimensional arrays but I took the easy way out.

Now for the problem: I have a huge array like
Code:
$array['2009-01-01'][1][37589]['Obama']['something']['again something']['another few levels']
$array['2009-01-02'][1][37589]['Obama']['some']['again something']['another few levels']
$array['2009-01-02'][2][37589]['Obama']['value']['again something']['another few levels']
$array['2009-01-01'][1][37599]['Bush']['sometng']['something']['another few levels']

And I want to sort it by lastname.

Anyone know a quick way to do this?

or am I stuck walking through the array with nested foreaches?

Thanx
#2

[eluser]pistolPete[/eluser]
Where do you get that array from? Isn't it possible to sort it beforehand?
You can try array_multisort() or uksort(), but since you mixed up associative and indexed arrays it's hard to do.

Why do you want to sort it by lastname? What do you want to do with the sorted array?
#3

[eluser]rogierb[/eluser]
The array is build using resultsets from different tables from several different databases on several different servers. So unfortunately it is not possible to sort on forehand.

As for array multisort() and uasort() or uksort() I still have to go into nested loops, don't I?

It has to be sorted bij lastname and/or firstname since we create a table with data regarding dutyrosters and timetables




Theme © iAndrew 2016 - Forum software by © MyBB