How to use array_multisort to sort an array

167 Views Asked by At

I want to sort these arrays and put the highest percentage values first. I keep getting errors when I try it such as uneven arrays so I unset the [status] key because I actually dont need it and it is still not working for me.

Here is the array I am trying to sort:

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
)

Here is my code:

       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

There are 0 best solutions below