SeekableIterator::seek

(PHP 5 >= 5.1.0, PHP 7)

SeekableIterator::seekSeeks to a position

说明

abstract public SeekableIterator::seek ( int $position ) : void

Seeks to a given position in the iterator.

参数

position

The position to seek to.

返回值

没有返回值。

错误/异常

Implementations should throw an OutOfBoundsException if the position is not seekable.

范例

Example #1 SeekableIterator::seek() example

Seek to the item at position 3 in the iterator (ArrayIterator implements SeekableIterator).

<?php
$array 
= array("apple""banana""cherry""damson""elderberry");
$iterator = new ArrayIterator($array);
$iterator->seek(3);
echo 
$iterator->current();
?>

以上例程的输出类似于:

damson

参见

相关文章
php ibm db2 函数 returns the position of the named column in a result setphp grapheme 函数 find position in grapheme units of first occurrence of a case insensitive stringphp zlib 函数 tell gz file pointer read/write positionphp informix 函数 returns the current file or seek positionphp 多字节字符串 函数 returns position and length of a matched part of the multibyte regular expression for a predefined multibyte stringphp ncurses 函数 insert character moving rest of line including character at current positionphp ncurses 函数 move output positionphp ncurses 函数 move current position and add characterphp ncurses 函数 move position and add attributed string with specified lengthphp ncurses 函数 draws a horizontal line in a window at current position using an attributed character and max. n characters longphp ps 函数 sets position for text outputphp harupage begin a text object and set the current text position to 0 0 php harupage print text at the current position of the pagephp harupage move the current position to the start of the next line and print the textphp intlbreakiterator set the iterator position to the first boundary before an offsetphp intlbreakiterator set the iterator position to the boundary immediately before the currentphp intlrulebasedbreakiterator get the largest status value from the break rules that determined the current break positionphp intlrulebasedbreakiterator get the status values from the break rules that determined the current break positionphp limititerator seek to the given positionphp seekableiterator seeks to a position
关注编程学问公众号