Re: Sort of a multidimensional array

From: Date: Wed, 11 Jun 2003 09:49:32 +0000
Subject: Re: Sort of a multidimensional array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-151036@lists.php.net to get a copy of this message
At 11:18 11-6-03, you wrote:
Hi, Is there a simple way to sort the following array structure by the array cell 'title'=>'TXxxxxx'? $x[0][0] = array(array('id'=>1,'title'=>'TXxxxxx'),array('id'=>2,'title'=>'T2')); $x[0][1] = array('id'=>10,'title'=>'Test1'); $x[1][0] = array(array('id'=>3,'title'=>'TXxxxxx'),array('id'=>6,'title'=>'T3')); $x[1][1] = array('id'=>11,'title'=>'Test2'); .
i am not a pro but what about rearranging the array so every element is containing its position, in stead of this being in the array structure? Suppose i name [0][0] to [pos1][ pos2] and each element would be an array of id,title, pos1,pos2: with your example: $x[]=array (1,'TXxxxxx',0,0), $x[]=array (2,'T2',0,0) $x[]=array (10,'Test1',0,1); $x[]=array (3,'TXxxxxx',1,0) $x[]=array (6,'T3',1,0) $x[]=array (11,'Test2',1,1); this would also be easy to smite in a database and then you can get it out by writing a query with ORDER by title But if you need to redo all your functions now, forget it.

« previous php.general (#151036) next »