Basic usage - lokothodida/php-arraypaginate GitHub Wiki

Index

Initialization

All that needs to be provided to the ArrayPaginate class is the Array that you wish to paginate.

$items = array(/* */);
$ap    = new ArrayPaginate($items);

Essential configuration

Call the paginate method to get the results, and as a parameter, give an Array whose keys are the configuration names.

// get the results
$results = $ap->paginate(array(
  'itemsPerPage' => /* max number of items per page, e.g. 5 */,
  'url'          => /* url for pagination links with %page% placeholder for page number
                       e.g. 'http://yoursite/path/to/page?p=%page%' */,
));

// output the pagination
echo $results['navigation'];

// use your results
foreach ($results['results'] as $result) {
  // ...
}

See the API for full configuration details.