PHP 简单数组分页

/**
 * 分页
 * $count_total总条数
 * $page_sum当前条数
 * $topicList需要分页的数组
 * $page_number当前页码数
 * 
 */
 function pagePage($page_sum,$page_number,$topicList)
 {
     $count_total = count($topicList);
     $merge_page = intval(floor($count_total / $page_sum)) + 1;//总页数
     $newarr['list'] = array_slice($topicList, ($page_number-1)*$page_sum, $page_sum);
     $merge['page'] = $merge_page;
     //合并数组
     $result = array_merge_recursive($newarr,$merge);
     return $result;
 }

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

Back To Top

鄂ICP备17008157号-1