I am trying to do a paging from single array
$input = Array
(
[0] => 'A',
[1] => 'B',
[2] => 'C'
...
)
example $show_per_page=2;
in page 1
paging($input,$page, $show_per_page);
$output = Array(
[0]=>'A',
[1]=>'B'
);
in page 2
$output = Array(
[2]=>'B'
);
I Know about array_slice but it is not right for this case.Anyone know how to do this?
Yes,
array_sliceis exactly what you want. It’s the most efficient way to do this. Here’s what you need.