abdulrhman-developer0 / php-datapaginator
此包用于将大数组分割成小数组并进行分页
v1.0
2024-03-30 01:59 UTC
Requires (Dev)
- symfony/var-dumper: 7.1.x-dev
README
安装
使用以下命令将此包安装到您的项目中。
composer require abdulrhman-developer0/php-datapaginator
简单使用
示例
<?php use AbdulrhmanDeveloper0\PhpDatapaginator\Paginator; // the dumy data to paginate. $items = array_fill(0, 100, 'page item'); // using the paginator. $paginator = new Paginator($items, 10); // get a specified page items. $page2 = $paginator->get(2);
分页器
示例
$paginator = new Paginator($data, 20);
关于此类构造函数的更多信息
/** * Initialize the paginator class * * @param array $items The data to split as pages. * @param int $itemsPerPage The count of items per page */ public function __construct(array $items = [], int $itemsPerPage = 10)
可用方法
在本部分文档中,我们将了解可用于此包中的方法。
/** * Retrieve items for any page through the page index * * @param int $pageNumber The page index * @return array The items of the page */ public function get(int $pageNumber): array;
/** * @return int|null Retunr the first page index if exists or null if not */ public function getFirstPage(): int|null;
/** * @return int|null Retunr the last page index if exists or null if not */ public function getLastPage(): int|null;