且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP数组多个排序 - 由键值呢?

更新时间:2023-11-27 11:18:34

看一看例子#3:
http://php.net/manual/en/function.array-multisort.php

您需要创建两个数组作为指标使用;一种制成了原始阵列的键和其他原始数组的值组成。

You'll need to create two arrays to use as indexes; one made up of the original array's keys and the other of the original array's values.

然后使用multisort由文本值(原始数组的键)进行排序,然后由数值(原始数组的值)。

Then use multisort to sort by text values (keys of the original array) and then by the numeric values (values of the original array).