我知道这已经发布过,但我无法让它为我工作:s 不知道为什么!但是 anywhooo 我的数组 $servers 看起来像这样
Array
(
[0] => Array
(
[0] => Dell PowerEdge R210 II
[1] => 8
[2] => Array
(
[0] => 8
[1] => Sock
[2] => Price
[3] => ImageURL
[4] => CPU
[5] => Memory
[6] => HDD
[7] => Bandwidth
[8] => OS
[9] => Upgrades
[10] => OrderLink
)
)
[1] => Array
(
[0] => Dell PowerEdge R210 II 2
[1] => 2
[2] => Array
(
[0] => 2
[1] => Sock
[2] => Price
[3] => ImageURL
[4] => CPU
[5] => Memory
[6] => HDD
[7] => Bandwidth
[8] => OS
[9] => Upgrades
[10] => OrderLink
)
)
[2] => Array
(
[0] => Dell PowerEdge R210 II 3
[1] => 3
[2] => Array
(
[0] => 3
[1] => Sock
[2] => Price
[3] => ImageURL
[4] => CPU
[5] => Memory
[6] => HDD
[7] => Bandwidth
[8] => OS
[9] => Upgrades
[10] => OrderLink
)
)
[3] => Array
(
[0] => Dell PowerEdge R210 II 4
[1] => 4
[2] => Array
(
[0] => 4
[1] => Sock
[2] => Price
[3] => ImageURL
[4] => CPU
[5] => Memory
[6] => HDD
[7] => Bandwidth
[8] => OS
[9] => Upgrades
[10] => OrderLink
)
)
[4] => Array
(
[0] => Dell PowerEdge R210 II 5
[1] => 5
[2] => Array
(
[0] => 5
[1] => Sock
[2] => Price
[3] => ImageURL
[4] => CPU
[5] => Memory
[6] => HDD
[7] => Bandwidth
[8] => OS
[9] => Upgrades
[10] => OrderLink
)
)
[5] => Array
(
[0] => Dell PowerEdge R210 II 6
[1] => 6
[2] => Array
(
[0] => 6
[1] => Sock
[2] => Price
[3] => ImageURL
[4] => CPU
[5] => Memory
[6] => HDD
[7] => Bandwidth
[8] => OS
[9] => Upgrades
[10] => OrderLink
)
)
)
我想重新排列阵列并放回 $servers 但按 $servers[x][1] 的顺序
所以奇异数在哪里(第一个对象是 8)我希望它用最小的数字 1 对它进行排序,移动到最大的!
非常感谢
ps 我试过这个
<?php
function cmp($a, $b)
{
if ($a == $b) {
return 0;
}
return ($a < $b) ? -1 : 1;
}
$a = array(3, 2, 5, 6, 1);
usort($servers, "cmp");
?>
但它似乎没有工作!
谢谢