note 97209 deleted from class.iterator by danbrown
| From: | danbrown@php.net | Date: | Thu, 08 Apr 2010 13:26:34 +0000 |
| Subject: | note 97209 deleted from class.iterator by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-168014@lists.php.net to get a copy of this message | ||
Note Submitter: cahnory at gmail dot com
Reason: non-english
----
Petit exemple avec un tableau indexé :
<?php
class className implements Iterator
{
private $_array = array();
private $_cursor = 0;
function rewind() {
$this->_cursor = 0;
}
function current() {
$keys = array_keys($this->_array);
return $this->_array[$keys[$this->_cursor]];
}
function key() {
return $this->_cursor;
}
function next() {
++$this->_cursor;
}
function valid() {
$keys = array_keys($this->_array);
return isset($keys[$this->_cursor]);
}
}
?>