You are here: Re: sort multi-dimensional array « PHP Programming Language « IT news, forums, messages
Re: sort multi-dimensional array

Posted by Balaskas Evaggelos on 10/05/65 11:56

mootmail-googlegroups@yahoo.com wrote:
> Balaskas Evaggelos wrote:
>> thanks for your anwser but the first thing i checked,
>> before i wrote this post, was that url.
>>
>> The example are for multi-dimensional array of one-dimensional arrays.
>>
>> I can't find how i can sort a multi-dimensional array of array[m][n]
>> and for a specific field example n=2.
>
> Maybe I just am not understanding you correctly, but aren't they the
> same thing?
> In PHP:
> $ar['m']['n'] = 1;
> is equivalent to:
> $ar = array('m' => array('n' => 1));
>
> Both can be referenced as $ar['m']['n'].
>
> Off the top of my head, the most relevant example from that php manual
> page would be Example 3. Sorting database results. It sounds like you
> want to essentially sort a 'table' of data by one of the columns. The
> concepts of that example should point you in the right direction.
> Unless, as I said, I am completely misunderstanding your question.
>

maybe i don't write it correctly - bad english :)

in the example 3 the multi-dimensional array breaks into two
one-dimensional arrays to sort them. So the results is
sorted for every separated array.

i need the 2 arrays to be sorted only by the second field of the second
array. And all the rest to be sorted according by this field.

this is my array:

arr[0][0]
arr[0][1]
arr[0][2]
arr[0][3]
arr[0][4]
arr[0][5]

arr[1][0]
arr[1][1]
arr[1][2]
arr[1][3]
arr[1][4]
arr[1][5]

....
....

i want to sort the arr be second element into the arr:

arr[m][2], and everything else will follow this order.

---
as m: 0,1,2,3,4,5,6,7,8,9,...
as n: 0,1,2,3,4,5,6,7,8,9,...

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация