PHPackages                             stefangabos/zebra\_pagination - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. stefangabos/zebra\_pagination

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

stefangabos/zebra\_pagination
=============================

A generic, Twitter Bootstrap compatible, PHP pagination library that automatically generates navigation links

2.4.9(3mo ago)11122.9k↓26.5%75LGPL-3.0PHPPHP &gt;=5CI passing

Since Jan 4Pushed 3mo ago11 watchersCompare

[ Source](https://github.com/stefangabos/Zebra_Pagination)[ Packagist](https://packagist.org/packages/stefangabos/zebra_pagination)[ Docs](https://github.com/stefangabos/Zebra_Pagination)[ GitHub Sponsors](https://github.com/stefangabos)[ RSS](/packages/stefangabos-zebra-pagination/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (16)Used By (0)

[![zebrajs](https://github.com/stefangabos/zebrajs/raw/master/docs/images/logo.png)](https://github.com/stefangabos/zebrajs/blob/master/docs/images/logo.png)

Zebra Pagination [![Tweet](https://camo.githubusercontent.com/cb820a0ecc9645168e33b03925d7f14691262ddbaeaf66a0a91697803d0cba2d/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f75726c2f687474702f736869656c64732e696f2e7376673f7374796c653d736f6369616c)](https://twitter.com/intent/tweet?text=A+generic,+Twitter+Bootstrap+compatible,+pagination+library+that+automatically+generates+navigation+links&url=https://github.com/stefangabos/Zebra_Pagination&via=stefangabos&hashtags=php)
=========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#zebra-pagination-)

*A generic, Twitter Bootstrap compatible, pagination library that automatically generates navigation links*

[![Latest Stable Version](https://camo.githubusercontent.com/494eba46a95a6bf27391792b375e5bf9cf51cd7491c18d1c5a3167fc204ff2aa/68747470733a2f2f706f7365722e707567782e6f72672f73746566616e6761626f732f7a656272615f706167696e6174696f6e2f762f737461626c65)](https://packagist.org/packages/stefangabos/zebra_pagination) [![Total Downloads](https://camo.githubusercontent.com/3f473325a34dc551f337d426191d3bd0b7422ecfc4077258e1a46e90ce8e8084/68747470733a2f2f706f7365722e707567782e6f72672f73746566616e6761626f732f7a656272615f706167696e6174696f6e2f646f776e6c6f616473)](https://packagist.org/packages/stefangabos/zebra_pagination) [![Monthly Downloads](https://camo.githubusercontent.com/d13d4dcd363853dd5136b20dc56d2b964bfdf31cd66d4cbd8925086535865a31/68747470733a2f2f706f7365722e707567782e6f72672f73746566616e6761626f732f7a656272615f706167696e6174696f6e2f642f6d6f6e74686c79)](https://packagist.org/packages/stefangabos/zebra_pagination) [![Daily Downloads](https://camo.githubusercontent.com/294f3f02cc99e15d7e414193487ed6de58c33270642d39d108f3f511d6d32284/68747470733a2f2f706f7365722e707567782e6f72672f73746566616e6761626f732f7a656272615f706167696e6174696f6e2f642f6461696c79)](https://packagist.org/packages/stefangabos/zebra_pagination) [![License](https://camo.githubusercontent.com/7450c5a7700e22d33f2a0606cf3f90336673d4284d89acd4b2df9f939b00f241/68747470733a2f2f706f7365722e707567782e6f72672f73746566616e6761626f732f7a656272615f706167696e6174696f6e2f6c6963656e7365)](https://packagist.org/packages/stefangabos/zebra_pagination)

A generic, [Twitter Bootstrap](http://getbootstrap.com) compatible (versions 3, 4 and 5), pagination script that automatically generates navigation links as well as next/previous page links, given the total number of records and the number of records to be shown per page. Useful for breaking large sets of data into smaller chunks, reducing network traffic and, at the same time, improving readability, aesthetics and usability.

Adheres to pagination best practices (provides large clickable areas, doesn't use underlines, the selected page is clearly highlighted, page links are spaced out, provides "previous page" and "next page" links, provides "first page" and "last page" links - as outlined in an article by Faruk Ates from 2007, which can now be found [here](https://gist.github.com/622561), can generate links both in natural as well as in reverse order, can be easily, localized, supports different positions for next/previous page buttons, supports page propagation via GET or via URL rewriting, is SEO-friendly, and the appearance is easily customizable through CSS.

> Please note that this is a *generic* pagination script, meaning that it does not display any records and it does not have any dependencies on database connections or SQL queries, making it very flexible! It is up to the developer to fetch the actual data and display it based on the information returned by this pagination script. The advantage is that it can be used to paginate over records coming from any source like arrays or databases.

The code is heavily commented and generates no warnings/errors/notices when PHP's error reporting level is set to E\_ALL.

Features
--------

[](#features)

- it is a generic library: can be used to paginate records both from an array or from a database
- it automatically generates navigation links, given the total number of items and the number of items per page (examples of best practices are also included)
- navigation links can be generated in natural or in reverse order
- it is SEO-friendly - it solves the problem of duplicate content on the first page without navigation and the first page having the page number in the URL
- appearance is easily customizable through CSS
- compatible with [Twitter Bootstrap](http://getbootstrap.com) versions 3, 4 and 5
- code is heavily commented and generates no warnings/errors/notices when PHP's error reporting level is set to E\_ALL
- has [awesome documentation](https://stefangabos.github.io/Zebra_Pagination/Zebra_Pagination/Zebra_Pagination.html)

📔 Documentation
---------------

[](#notebook_with_decorative_cover-documentation)

Check out the [awesome documentation](https://stefangabos.github.io/Zebra_Pagination/Zebra_Pagination/Zebra_Pagination.html)!

🎂 Support the development of this project
-----------------------------------------

[](#-support-the-development-of-this-project)

Your support means a lot and it keeps me motivated to keep working on open source projects.
If you like this project please ⭐ it by clicking on the star button at the top of the page.
If you are feeling generous, you can buy me a coffee by donating through PayPal, or you can become a sponsor.
Either way - **Thank you!** 🎉

[![Star it on GitHub](https://camo.githubusercontent.com/3da09fc2b94c984b84b0e1ba80eb3bdd1cc39eff6cd446bc03a6fc5e92119ca7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f73746566616e6761626f732f7a656272615f706167696e6174696f6e3f636f6c6f723d677265656e266c6162656c3d7374617225323069742532306f6e253230476974487562)](https://github.com/stefangabos/Zebra_Pagination) [![Donate](https://camo.githubusercontent.com/604e3db9c8751116b3f765aad0353ec7ded655bbe8aaacbc38d8c4a6b784b3ed/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d50617950616c2d677265656e2e737667)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SKXN7C6PPH6FL) [![](https://camo.githubusercontent.com/7a6725dd6857bfabaca4b6783ac9ff3c2e882456681b5fdfb1fae916c0461c73/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2d53706f6e736f722d6661666266633f6c6f676f3d47697448756225323053706f6e736f7273)](https://github.com/sponsors/stefangabos)

Requirements
------------

[](#requirements)

PHP 5+

Installation
------------

[](#installation)

You can install Zebra Pagination via [Composer](https://packagist.org/packages/stefangabos/zebra_pagination)

```
# get the latest stable release
composer require stefangabos/zebra_pagination

# get the latest commit
composer require stefangabos/zebra_pagination:dev-master
```

Or you can install it manually by downloading the latest version, unpacking it, and then including it in your project

```
require_once 'path/to/Zebra_Pagination.php';
```

How to use
----------

[](#how-to-use)

Make sure that in the of your page you have

```

```

If you want to preserve hashes in the URL, also include the JavaScript file – simply including it will suffice; (jQuery needs to also be loaded before loading this file)

```

```

Paginate data from an array:

**The PHP**

```
