微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

原文地址:https://www.jb51.cc/php/134098.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐