I have a zend paginator object, I want to get the first element in this paginator.
I tried $paginator->getItem(0)
but it returns the message:Message: Cannot seek to 0 which is below the offset 2
. And the $paginator->count() is 19.
I can achieve this by using foreach:
foreach ($paginator as $item)
{
$entry = $item;
}
How can I get this by not using foreach?
This will give you the first item without using foreach:
$first = current($paginator->getItemsByPage(1)); // Get the first item
$firstCurrent = current($paginator->getCurrentItems()); // Get the first item of the current pages
It should be
$paginator->getCurrentItems()->current();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With