views:

448

answers:

1

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

A: 

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

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

Zak