【发布时间】:2017-04-13 14:40:57
【问题描述】:
这个数组:
$aShips = array('0_204' => 1, '0_205' => 2, '0_206' => 3, '0_207' => 4);
必须是:
array(4) { ["'0_206'"]=> int(3) ["'0_205'"]=> int(2) ["'0_204'"]=> int(1) ["'0_207'"]=> int(4) }
//order like this (can be different)
$order = array("0_206", "0_205", "0_204", "0_207");
//this sort it not like my custom order
function cmp($a, $b){
if ($a==$b) return 0;
return ($a<$b)?-1:1;
}
uasort($aShips, "cmp");
【问题讨论】:
-
为什么
0_207会在数组的末尾 -
这只是一个例子。我想每次都像我的 $order 数组一样订购 $aShips 数组。 (带 val 的键)