我有一个数组,
样本:
$array {
[0] {
[something]=1;
[something2]=2;
}
[1] {
[something]=2;
[something2]=4;
}
[2] {
[something]=5;
[something2]=2;
}
}
我想根据键某事对数组进行排序;
所以它看起来像:
$array {
[0] {
[something]=5;
[something2]=2;
}
[1] {
[something]=2;
[something2]=4;
}
[2] {
[something]=1;
[something2]=2;
}
}
function compare($x, $y) {
return $x['something'] - $y['something'];
}
usort($input_array, 'compare');
你需要使用usort()与上面类似。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)