如何使用array_multisort对数组进行排序

时间:2013-08-31 16:50:36

标签: php array-multisort

我想对这些数组进行排序,并将最高百分比值放在第一位。 当我尝试它时不断出现错误,例如不均匀的数组,所以我取消设置[status]键,因为我实际上不需要它,它仍然不适合我。

这是我要排序的数组:

Array
(
    [position] => RB
    [name] => Stewart, Jeremy
    [team] => OAK
    [percent] => 3.15
)
Array
(
    [position] => RB
    [name] => Stewart, Jeremy
    [team] => OAK
    [percent] => 3.15
)
Array
(
    [status] => R
    [position] => QB
    [name] => Smith, Geno
    [team] => NYJ
    [percent] => 2.67
)
Array
(
    [status] => R
    [position] => QB
    [name] => Smith, Geno
    [team] => NYJ
    [percent] => 2.67
)

这是我的代码:

       foreach( $dropsOutput as $key => $category ) { 
          unset($category['id']);
          //unset($category['status']);

         if (array_key_exists("percent", $category)) { 
           foreach( $category as $index => $value ) { 

             echo "<pre>"; 
             print_r($category);
             echo "</pre>";                   
           }  
         }                    
       }

0 个答案:

没有答案