You are here: Re: Sort an array « PHP Programming Language « IT news, forums, messages
Re: Sort an array

Posted by Erwin Moller on 10/27/52 11:40

iavian wrote:

> Hi
>
>
> How do we sort 3 dimensional array by sorting on 3 , 2 and 1st
> dimensions?
>
>
> Regards
> Vijay

Hi,

PHP doesn't really have multidimensional arrays.
What PHP does have is tough to explain, but it is easiest to think of arrays
that have arrays as elements.
that elements can be arrays again.
This can be repeated many times.

So eg: a 5x5x5 array:

// not needed, but makes things easier to read.
$ar = array();

// fill it
$ar[0][0] = array(1,2,3,'bla',3.14);
$ar[0][1] = array(2,3,44,'testing',99);

etc.

untill

$ar[4][4] = array(44,-34,4,'last',9);

So HOW do you want it sorted now?

Have a look at functions like: uksort at www.php.net
They allow you to write your own compare-function which PHP will use to
sort.

Regards,
Erwin Moller

 

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

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