$data['reg'] = $this->register->registerAcc($schoolID); $data['upd'] =$this->register->UpdateAcc($schoolID); $data['sus'] =$this->register->suspendAcc($schoolID);$this->load->view('account/accountInfo',$data);这是我的代码,由更新、注册和暂停组成。每个功能都有自己的“日期/时间”函数的每一端都有这样的代码:$this->db->order_by('register_Date','DESC');每个函数都有自己的日期,例如 register_Date , updateAcc_Date但是我有一个问题,当我在页面中显示时,列表将从Date Function UserName05-09-2019 Register Tom04-09-2019 Register Bors01-09-2019 Register Berry03-09-2019 Update Laxy 05-09-2019 Suspend Loi我想要的是Date Function UserName05-09-2019 Register Tom05-09-2019 Suspend Loi04-09-2019 Register Bors03-09-2019 Update Laxy 01-09-2019 Register Berry
1 回答
慕丝7291255
TA贡献1859条经验 获得超6个赞
设置日期与喜欢相同的密钥date在$data数组中,然后使用usort()功能
$data = Array
(
[0] => Array
(
[Function] => 'register'
[datetime] => 2010-05-26 15:59:53
)
[1] => Array
(
[Function] => 'update'
[datetime] => 2010-05-26 16:04:24
)
)
function date_compare($a, $b)
{
$t1 = strtotime($a['datetime']);
$t2 = strtotime($b['datetime']);
return $t1 - $t2;
}
usort($data, 'date_compare');
print_r($data);
- 1 回答
- 0 关注
- 120 浏览
添加回答
举报
0/150
提交
取消