class.collectioniterator.php
来自「Professional PHP5 code for this book」· PHP 代码 · 共 34 行
PHP
34 行
<?class CollectionIterator implements Iterator { private $_collection; private $_currIndex = 0; private $_keys; function __construct(Collection $objCol) { $this->_collection = $objCol; $this->_keys = $this->_collection->keys(); } function rewind() { $this->_currIndex = 0; } function hasMore() { return $this->_currIndex < $this->_collection->length(); } function key() { return $this->_keys[$this->_currIndex]; } function current() { return $this->_collection->getItem($this->_keys[$this->_currIndex]); } function next() { $this->_currIndex++; }}?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?