• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • LimitIterator::__construct()

    (PHP 5>=5.1.0,PHP 7)

    Construct a LimitIterator

    说明

    publicLimitIterator::__construct(Iterator$iterator[,int $offset=0[,int $count= -1]])

    Constructs a newLimitIteratorfrom an$iteratorwith a given starting$offsetand maximum$count.

    参数

    $iterator

    TheIteratorto limit.

    $offset

    Optional offset of the limit.

    $count

    Optional count of the limit.

    返回值

    The newLimitIterator.

    错误/异常

    Throws anOutOfRangeExceptionif the$offsetis less than0or the$countis less than-1.

    范例

    Example#1LimitIterator::__construct()example

    <?php
    $ait = new ArrayIterator(array('a', 'b', 'c', 'd', 'e'));
    $lit = new LimitIterator($ait, 1, 3);
    foreach ($lit as $value) {
        echo $value . "\n";
    }
    ?>
    

    以上例程会输出:

    b
    c
    d
    

    参见

    • LimitIterator examples