开发者

Codeigniter Pagination over array instead of Database resultset

I have looked into trying to use the pagination class within codigniter but for my problem I need to paginate over an array of data and not a database table. In my code I create a custom array and then pass开发者_StackOverflow中文版 that array to the view using the standard

$this->load->vars($myarray);
$this->load->view('myview', $myarray);

Everything works fine in that sense but the $myarray at times can be really large. I really want to try and create some sort of pagination on the view that will only dislpay the first 25 of the array but the more I read about the Pagination class within codeigniter it looks like you can only paginate over database tables. Does anyone know how I might achieve this? Thanks


Can't you just slice up the array yourself before loading it into the view?

http://us3.php.net/array_slice Give array_slice the page offset and result count and it will basically do exactly what you want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜