我正在尝试根据多维数组中的特定键值对数组进行排序,如下所示
<?php
$country = array(
array(
'country' => 'India',
'visits' => 22,
'newVisits' => 16,
'newVisitsPercent' => 72.7),
array(
'country' => 'USA',
'visits' => 30,
'newVisits' => 15,
'newVisitsPercent' => 50),
array(
'country' => 'Japan',
'visits' => 25,
'newVisits' => 15,
'newVisitsPercent' => 60));
?>
我想按数组的“访问”键的降序对数组进行排序。
所需的数组是
<?php
$country = array(
array(
'country' => 'USA',
'visits' => 30,
'newVisits' => 15,
'newVisitsPercent' => 50),
array(
'country' => 'Japan',
'visits' => 25,
'newVisits' => 15,
'newVisitsPercent' => 60),
array(
'country' => 'India',
'visits' => 22,
'newVisits' => 16,
'newVisitsPercent' => 72.7));
?>
试图在 SO 中搜索所有结果都根据键的值进行排序。请让我知道我们需要使用哪个功能。
我查看了 ksort,多排序功能