I'm making pagination and testing it right now. I have one question on here. Let's say I have array $list:
$list = {
[0] => array(~){~, ~, ...}
[1] => array(~){~, ~, ...}
...
[34]=> array(~){~, ~, ...}
}
$all_count = count($list) // 35
// pseudo code
function pagination($list, $page) { //$page = requesting page from $_get.(defalut = 1)
$all_count = count($list);
$page_slice = array_slice($list, ($page - 1) * 20, 20);
return $page_slice;
}
in the pagination function, I slice $list every 20 per page. as a return value of pagination function, I'd like to return both $page_slice for contents of page and $all_count for pagination parameter. But, If I put $all_count in the $page_slice element, pagination count it as contents and render wrong pagination ; ( Any example code very helpful for me Thank you : )