LimitIterator::getPosition

(PHP 5 >= 5.1.0, PHP 7)

LimitIterator::getPositionReturn the current position

说明

public LimitIterator::getPosition ( void ) : int

Gets the current zero-based position of the inner Iterator.

参数

此函数没有参数。

返回值

The current position.

范例

Example #1 LimitIterator::getPosition() example

<?php
$fruits 
= array(
    
'a' => 'apple',
    
'b' => 'banana',
    
'c' => 'cherry',
    
'd' => 'damson',
    
'e' => 'elderberry'
);
$array_it = new ArrayIterator($fruits);
$limit_it = new LimitIterator($array_it23);
foreach (
$limit_it as $item) {
    echo 
$limit_it->getPosition() . ' ' $item "\n";
}
?>

以上例程会输出:

2 cherry
3 damson
4 elderberry

参见

相关文章
php cachingiterator return the key for the current elementphp directoryiterator return path and file name of current directoryiterator itemphp directoryiterator check whether current directoryiterator position is a valid filephp cubrid mysql 兼容性函数 return the current cubrid connection charsetphp ncurses 函数 delete line at current position move rest of screen upphp ncurses 函数 scroll window content up or down without changing current positionphp ncurses 函数 draw a vertical line at current position using an attributed character and max. n characters longphp ncurses 函数 adds character at current position in a window and advance cursorphp ncurses 函数 draws a vertical line in a window at current position using an attributed character and max. n characters longphp posix 函数 return the real user id of the current processphp harupage get the current position for path paintingphp harupage get the current position for text printingphp limititerator return the current positionphp spldoublylinkedlist return current array entryphp splfileobject return current file positionphp splpriorityqueue return current node indexphp swfshape draws a cubic bezier curve using the current position and the three given points as control pointsphp swfshape draws a cubic bezier curve using the current position and the three given points as control pointsphp swoole connection iterator return current connection entry.php swoole connection iterator return key of the current connection.
关注编程学问公众号