|
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]
|