From 71f2a8edd291835761c7dbb70c2f7971e5e0d279 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Tue, 13 Apr 2004 15:14:06 +0000 Subject: [PATCH] completing spl/array docs git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@155856 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/spl/functions/ArrayIterator-key.xml | 21 +++++++++-- .../spl/functions/ArrayIterator-next.xml | 36 +++++++++++++++++-- .../spl/functions/ArrayIterator-rewind.xml | 28 +++++++++++++-- 3 files changed, 79 insertions(+), 6 deletions(-) diff --git a/reference/spl/functions/ArrayIterator-key.xml b/reference/spl/functions/ArrayIterator-key.xml index f4daf487c1..11526973c7 100755 --- a/reference/spl/functions/ArrayIterator-key.xml +++ b/reference/spl/functions/ArrayIterator-key.xml @@ -1,5 +1,5 @@ - + ArrayIterator::key @@ -13,9 +13,26 @@ mixedArrayIterator::key + + This function returns the current array key + + + + <function>ArrayIterator::key</function> example + + 'value'); - &warn.undocumented.func; +$arrayobject = new ArrayObject($array); +$iterator = $arrayobject->getIterator(); +echo $iterator->key(); //key +?> +]]> + + + diff --git a/reference/spl/functions/ArrayIterator-next.xml b/reference/spl/functions/ArrayIterator-next.xml index 62ddf5f215..0e08756956 100755 --- a/reference/spl/functions/ArrayIterator-next.xml +++ b/reference/spl/functions/ArrayIterator-next.xml @@ -1,5 +1,5 @@ - + ArrayIterator::next @@ -13,9 +13,41 @@ voidArrayIterator::next + + This function moves the iterator to the next entry. + + + + <function>ArrayIterator::next</function> example + +getIterator(); + +while($iterator->valid()) { + echo $iterator->key() . ' => ' . $iterator->current() . "\n"; + + $iterator->next(); +} +?> +]]> + + + The above example will output: + + + zero +1 => one +]]> + + + diff --git a/reference/spl/functions/ArrayIterator-rewind.xml b/reference/spl/functions/ArrayIterator-rewind.xml index f2b26f4269..0493a4d19c 100755 --- a/reference/spl/functions/ArrayIterator-rewind.xml +++ b/reference/spl/functions/ArrayIterator-rewind.xml @@ -1,5 +1,5 @@ - + ArrayIterator::rewind @@ -13,9 +13,33 @@ voidArrayIterator::rewind + + This function rewinds the iterator to the begining. + + + + <function>ArrayObject::rewind</function> example + +getIterator(); + +$iterator->next(); +echo $iterator->key(); //1 + +$iterator->rewind(); //rewinding to the begining +echo $iterator->key(); //0 +?> +]]> + + +