Re: sorting associative array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

How about this....


      foreach ($data as $key => $row) {
	$scores[$key] = $row['scores'];
      }
     array_multisort($scores, SORT_ASC, $data);


Abdul-Wahid


On Mon, 24 Jan 2005 00:39:17 +1100, Jeffery Fernandez
<forums@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> I have the following multi-dimentional array and I want to sort it by
> the "score" key value
> 
> print_r($data);
> 
> Array
> (
>     [0] => Array
>         (
>             [video_id] => 71
>             [old_id] => 7854
>             [title] => When the fire comes
>             [video_copies] => 1
>             [running_time] => 48
>             [date_published] => 06/02
>             [place_published] => Australia
>             [abstract] => ABC TV Gives details on many aspects of bushfires: .......................
>             [library_medium_id] => 5
>             [library_type] => 4
>             [score] => 6.3310546875
>         )
> 
>     [1] => Array
>         (
>             [video_id] => 9
>             [old_id] => 7792
>             [title] => Fire awareness
>             [video_copies] => 1
>             [running_time] => 15
>             [date_published] =>
>             [place_published] => Victoria
>             [abstract] => Safetycare Australia A general video lookin.........
>             [library_medium_id] => 5
>             [library_type] => 4
>             [score] => 3.1997931003571
>         )
> 
> )
> 
> any ideas. Thanks
> 
> Jeffery
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux