我有以下数组,我想在php中的“count”索引值的基础上以降序对这个数组进行排序。我已经使用了下面的代码,但它不适合我。请给我提示按降序对数组进行排序。如何排序在php中降序数组中的二维数组?
阵列: -
Array ([0] => Array ([text] => this is text [count] => 0)
[1] => Array ([text] => this is second text [count] => 2)
[2] => Array ([text] => this is third text [count] => 1)
)
我曾尝试下面的代码。
function sort_count($a, $b) {
return $a['count'] - $b['count'];
}
$sorted_array = usort($array, 'sort_count');
它已经有一个解决方案在这里:http://stackoverflow.com/questions/2699086/sort-multi-dimensional-array-by-value –