日期:2014-05-17 浏览次数:20460 次
function array_order(&$ar, $by) { asort($by); foreach($by as $k=>$v) { $r[$k] = $ar[$k]; } return $ar = $r; } $arr = array( 'a' => 'aa', 'b' => 'bb', 'c' => 'cc', ); $sort_by = array( 'a' => 2, 'b' => 3, 'c' => 1, ); array_order($arr, $sort_by); print_r($arr);
------解决方案--------------------
array_multisort($sort_by,SORT_ASC,$arr);
print_r($arr);