-
-
//php排序函数实例
- function array_sort($arr,$keys,$type='asc')
- {
- echo'开始排序...'.'';
- $keysvalue = $new_array = array();
- foreach ($arr as $k=>$v)
- {
- $keysvalue[$k] = $v[$keys];
- }
- if($type == 'asc')
- {
- asort($keysvalue);
- }
- else
- {
- arsort($keysvalue);
- }
- reset($keysvalue);
- foreach ($keysvalue as $k=>$v)
- {
- $new_array[$k] = $arr[$k];
- }
- echo'排序结束...'.'';
- return $new_array;
- }
复制代码
|