我有一个数组,看起来像下面的一个。我需要按点数从最高到最低排序。我已经尝试了所有的排序功能,并且有些会带来疯狂的结果。
(
[0] => Array
(
[name] => Shane Jones
[points] => 43
)
[1] => Array
(
[name] => Katie 'Kitty' Youd
[points] => 50
)
[2] => Array
(
[name] => Steve Bennett
[points] => 50
)
[3] => Array
(
[name] => Sharon Harvey
[points] => 99
)
[4] => Array
(
[name] => Sean Dentith
[points] => 50
)
)
呀,你的问题出现了,因为它是一个多维数组,数组排序功能只会影响最外层阵列。这个数组是如何创建的?它是硬编码还是来自数据源,如数据库或XML文件? –
类似的问题已经提出*和*回答:[在PHP中排序关联数组](http://stackoverflow.com/questions/777597/sorting-an-associative-array-in-php)。请下次使用搜索功能。请参阅[常见问题](http://stackoverflow.com/faq)。 – hakre