PHP二维数组排序(sort_array)
2015-08-05 22:12
721 查看
/** * 对二维数组进行排序 * @param $array * @param $keyid 排序的键值 * @param $order 排序方式 'asc':升序 'desc':降序 * @param $type 键值类型 'number':数字 'string':字符串 */ function sort_array(&$array, $keyid, $order = 'asc', $type = 'number') { if (is_array($array)) { foreach($array as $val) { $order_arr[] = $val[$keyid]; } $order = ($order == 'asc') ? SORT_ASC: SORT_DESC; $type = ($type == 'number') ? SORT_NUMERIC: SORT_STRING; array_multisort($order_arr, $order, $type, $array); } }
相关文章推荐
- PHP二维数组排序(sort_array)
- source-php-usort
- PHP get_class 返回对象的类名
- 5.PHP 教程_PHP echo/print
- 深入PHP内核之函数和返回值
- Mac 10.10 web环境配置之php+mysql小结
- DayuCMS 1.525 /include/global.func.php Foreground Arbitrary Code Execution
- PHP生成word的三种方式
- func_get_arg,func_get_args,func_num_args实现PHP伪重载
- PHP应用API接口实现
- php调用SQL SERVER 2008及以上版本的方法
- Yii 1.x IOS推送
- FileOutputStream中的 3种write方式
- zendframework form with captcha(Base on ZendFrameWork2.4)
- php实现分页调取数据库记录
- zend 环境
- 5种php加密工具zendGuard、ionCube、SourceCop、SourceGuardian、phpShield
- yii 时间控件 输入框
- 发送邮件(遵循smtp协议即简单的邮件发送协议)
- php数组