Re: Sorting multi-dimensional arrays
| From: | Joe Stump | Date: | Mon, 30 Oct 2000 18:07:02 +0000 |
| Subject: | Re: Sorting multi-dimensional arrays | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-22714@lists.php.net to get a copy of this message | ||
http://www.php.net/manual/function.array-multisort.php
--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-
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
================================================================================
= Joe Stump joestump98@yahoo.com http://www.miester.org =
================================================================================
"Real programmers don't comment their code.
It was hard to write, it should be hard to understand."