mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Patch submitted by anonymous person via online editor
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@306851 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
953e9ec5b2
commit
ca6478c611
1 changed files with 16 additions and 25 deletions
|
@ -82,7 +82,6 @@ private => private var
|
|||
class MyIterator implements Iterator
|
||||
{
|
||||
private $var = array();
|
||||
private $index = 0;
|
||||
|
||||
public function __construct($array)
|
||||
{
|
||||
|
@ -94,43 +93,35 @@ class MyIterator implements Iterator
|
|||
public function rewind()
|
||||
{
|
||||
echo "rewinding\n";
|
||||
$this->index = 0;
|
||||
reset($this->var);
|
||||
}
|
||||
|
||||
|
||||
public function current()
|
||||
{
|
||||
$k = array_keys($this->var);
|
||||
$var = $this->var[$k[$this->index]];
|
||||
$var = current($this->var);
|
||||
echo "current: $var\n";
|
||||
return $var;
|
||||
}
|
||||
|
||||
public function key()
|
||||
|
||||
public function key()
|
||||
{
|
||||
$k = array_keys($this->var);
|
||||
$var = $k[$this->index];
|
||||
$var = key($this->var);
|
||||
echo "key: $var\n";
|
||||
return $var;
|
||||
}
|
||||
|
||||
public function next()
|
||||
|
||||
public function next()
|
||||
{
|
||||
$k = array_keys($this->var);
|
||||
if (isset($k[++$this->index])) {
|
||||
$var = $this->var[$k[$this->index]];
|
||||
echo "next: $var\n";
|
||||
return $var;
|
||||
} else {
|
||||
echo "next:\n";
|
||||
return false;
|
||||
}
|
||||
$var = next($this->var);
|
||||
echo "next: $var\n";
|
||||
return $var;
|
||||
}
|
||||
|
||||
|
||||
public function valid()
|
||||
{
|
||||
$k = array_keys($this->var);
|
||||
$var = isset($k[$this->index]);
|
||||
echo "valid: {$var}\n";
|
||||
$key = key($this->var);
|
||||
$var = ($key !== NULL && $key !== FALSE);
|
||||
echo "valid: $var\n";
|
||||
return $var;
|
||||
}
|
||||
|
||||
|
@ -163,7 +154,7 @@ valid: 1
|
|||
current: 3
|
||||
key: 2
|
||||
2: 3
|
||||
next: (no more)
|
||||
next:
|
||||
valid:
|
||||
]]>
|
||||
</screen>
|
||||
|
|
Loading…
Reference in a new issue