Re: Sorting multi-dimensional arrays

From: Date: Tue, 31 Oct 2000 08:24:19 +0000
Subject: Re: Sorting multi-dimensional arrays
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-22878@lists.php.net to get a copy of this message
"Joe Stump" <joe@earth.care2.com> wrote in message news:20001030100702.C31604@zorka.com... > http://www.php.net/manual/function.array-multisort.php > Yes, i have seen that one, but how would you use it to sort by a specific column? The manual does say that it "resembles the functionality of SQL ORDER BY clause", and that is exactly what i want, but i cant see how -- the examples all sorts the content the sub-arrays, and that is not what i want. -Tobias- > --Joe > > On Mon, Oct 30, 2000 at 03:52:31PM +0100, Tobias H. Michaelsen wrote: > > Is there a way to sort a multi-dimensional array by a specified collumn? > > > > ex. if i want to sort by the 3rd row: > > > > /=== > > | $ar = array( array( 23, 'kjhsdfjhd', 952106215, 'jkhg' ), > > | array( 24, 'zmncjdflf', 952103423, 'fgfg' ) ); > > | sort_multi_array_by_col( $ar, 2 ); > > \=== > > > > and then i get: > > > > $ar[0] => [ 24, 'zmncjdflf', 952103423, 'fgfg' ] > > $ar[1] => [ 23, 'kjhsdfjhd', 952106215, 'jkhg' ] > > > > Or perhaps by key-name: > > > > /=== > > | $ar = array( array( "name" => "John", "telephone" => > > "555-4321" ), > > | array( "name" => "Bob", "telephone" => > > "555-1234" ) ); > > | sort_multi_array_by_col( $ar, "telephone" ); > > \=== > > > > -Tobias- > >

« previous php.general (#22878) next »