Posted By

reiko on 06/29/07


Tagged

paging Pager LimitIterator SPL


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

koncept


LimitIterator


 / Published in: PHP
 

URL: http://www.php.net/~helly/php/ext/spl/classLimitIterator.html

SPL LimitIteratorの使い方 Pagerクラスを作る際のヒント

  1. $items = array(
  2. 'apple',
  3. 'lemon',
  4. 'orange',
  5. 'grape',
  6. 'melon',
  7. 'watermelon',
  8. 'strawberry',
  9. 'banana',
  10. 'mango',
  11. 'lime'
  12. );
  13.  
  14. $offset = 3;
  15.  
  16. $count = 5;
  17.  
  18.  
  19. $innerIterator = new ArrayIterator($items);
  20.  
  21. $itarator = new LimitIterator($innerIterator, $offset, $count);
  22.  
  23.  
  24. foreach ($iterator as $current) {
  25. print $current;
  26. }

Report this snippet  

You need to login to post a comment.