/**
* 二维数组指定字段排序
* @param $data
* @param $field
* @return mixed
*/
public function is_sort($data, $field)
{
$sort = array(
'direction' => 'SORT_DESC', //排序顺序标志 SORT_DESC 降序;SORT_ASC 升序
'field' => $field, //排序字段
);
$arrSort = array();
foreach ($data AS $uniqid => $row) {
foreach ($row AS $key => $value) {
$arrSort[$key][$uniqid] = $value;
}
}
if ($sort['direction']) {
array_multisort($arrSort[$sort['field']], constant($sort['direction']), $data);
}
return $data;
}
PHP二维数组指定字段排序
最新推荐文章于 2024-08-22 09:44:18 发布