日期:2014-05-17 浏览次数:20555 次
array( [0] = array( ['a'] = 323, ['b'] = array( ['b1'] = 1 ) ) [1] = array( ['a'] = 234, ['b'] = array( ['b1'] = 1 ) ) [2] = array( ['a'] = 135, ['b'] = array( ['b1'] = 2 ) ) )
<?php function cmp($a,$b){ return $a['b']['b1'] == $b['b']['b1']?($a['a'] - $b['a']):($a['b']['b1'] - $b['b']['b1']); } $array = array(0=>array('a'=>323,'b'=>array('b1'=>1)), 1=>array('a'=>324,'b'=>array('b1'=>1)), 2=>array('a'=>135,'b'=>array('b1'=>2)), ); usort($array,'cmp'); var_export($array);
------解决方案--------------------