PHP - Get Number of Pages

Daniel Harris picture Daniel Harris · Jul 24, 2012 · Viewed 10.7k times · Source

How do I get the number of pages if I know the total number of items there are and how many items are shown on each page? For example, I know that I have 11 items and each page shows 10 items. So I would have 2 pages. How would I get the number of pages in PHP?

Thanks

Answer

mrok picture mrok · Jul 24, 2012

Try ceil() function.

$pages = ceil($items/$itemsPerPage);