I'd like to know how to page through an array. I want to pass an integer value into a function and have that function return th开发者_Python百科at many rows of the array. If there are additional rows, then they need to be paged or limited as well by the integer value that was passed into the function.
Can someone help me get this down?
There is already a function for that:
= array_slice($array, $page * 10, 10);
// would return a block of ten array entries
I'd like to know how to page through an array.
Where do you get the array from? In my experience, arrays generally come from a data source such as a database. In such a case, I would suggest you simply use SQL to limit the number of returned rows;
SELECT your, fields FROM yourtable LIMIT 10 OFFSET 10;
Hope that might help you or anyone having the same issues.
精彩评论