对二维数组排序
function array_sort($arr, $row, $type='asc'){ $newArr = array(); foreach($arr as $v){ $newArr[$v[$row]] = $v; } if($type == 'asc'){ ksort($newArr); }else if($type == 'asc'){ krsort($newArr); }else{ echo "error"; } return $newArr; } $info = array( array('id' => 2, 'name' => 'zhangsan', 'age' => 23), array('id' => 5, 'name' => 'lisi', 'age' => 28), array('id' => 3, 'name' => 'apple', 'age'=> 17) ); print_r(array_sort($info, 'name'));