thinkphp5 数组分页

            //    每页数据数,当前页,数组,排序(0不变,1反序)
function page_array($count,$page,$array,$order){
    $page=(empty($page))?'1':$page; #判断当前页面是否为空 如果为空就表示为第一页面
    $start=($page-1)*$count; #计算每次分页的开始位置
    if($order==1){
        $array=array_reverse($array);
    }
    $pagedata=array();
    $pagedata=array_slice($array,$start,$count);    //分隔数组
    return $pagedata;  #返回查询数据
}

 

posted @ 2018-09-05 13:32  zrn  阅读(1214)  评论(0编辑  收藏  举报