php – Zend Paginator – 如何获得paginator中的第一个元素?

我有一个zend paginator对象,我想得到这个paginator中的第一个元素.

我尝试了$paginator-> getItem(0),但它返回消息:消息:无法寻找0低于偏移量2.而$paginator-> count()为19.

我可以通过使用foreach实现这一点:

foreach ($paginator as $item)
{
    $entry = $item;
}

如何通过不使用foreach来获得这个?

这将为您提供第一个不使用foreach的项目:
$first = current($paginator->getItemsByPage(1)); // Get the first item
$firstCurrent = current($paginator->getCurrentItems()); // Get the first item of the current pages

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...