我想对这些数组进行排序并将最高百分比值放在首位。当我尝试它时不断收到错误,例如不均匀的数组,所以我取消设置 [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>";
}
}
}