0

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 : )

Juno J
  • 187
  • 2
  • 11
  • Can you provide more codes on the usage side?? It is currently not clear what you want to achieve. – Vlam Feb 12 '20 at 02:26
  • Does this answer your question? [How can I return two values from a function in Python?](https://stackoverflow.com/questions/9752958/how-can-i-return-two-values-from-a-function-in-python) – Alessandro Da Rugna Feb 12 '20 at 07:45
  • Thx but no, language is different. So php cannot return two values while python can. sorry XI – Juno J Feb 12 '20 at 07:55

0 Answers0