ITERATORAGGREGATE(3) 1 ITERATORAGGREGATE(3)The IteratorAggregate interfaceINTRODUCTION
Interface to create an external Iterator.
INTERFACE SYNOPSIS
IteratorAggregate
IteratorAggregateextends
Traversable
Methods
o abstractpublic Traversable IteratorAggregate::getIterator (void )
Example #1
Basic usage
<?php
class myData implements IteratorAggregate {
public $property1 = "Public property one";
public $property2 = "Public property two";
public $property3 = "Public property three";
public function __construct() {
$this->property4 = "last property";
}
public function getIterator() {
return new ArrayIterator($this);
}
}
$obj = new myData;
foreach($obj as $key => $value) {
var_dump($key, $value);
echo "
";
}
?>
The above example will output something similar to:
string(9) "property1"
string(19) "Public property one"
string(9) "property2"
string(19) "Public property two"
string(9) "property3"
string(21) "Public property three"
string(9) "property4"
string(13) "last property"
PHP Documentation Group ITERATORAGGREGATE(3)
Check Out this Related Man Page
LIMITITERATOR(3) 1 LIMITITERATOR(3)The LimitIterator classINTRODUCTION
The LimitIterator class allows iteration over a limited subset of items in an Iterator.
CLASS SYNOPSIS
LimitIterator
LimitIteratorextends
IteratorIteratorOuterIterator
Methods
o public LimitIterator::__construct (Iterator $iterator, [int $offset], [int $count = -1])
o public mixed LimitIterator::current (void )
o public Iterator LimitIterator::getInnerIterator (void )
o public int LimitIterator::getPosition (void )
o public mixed LimitIterator::key (void )
o public void LimitIterator::next (void )
o public void LimitIterator::rewind (void )
o public int LimitIterator::seek (int $position)
o public bool LimitIterator::valid (void )
EXAMPLES
Example #1
LimitIterator usage example
<?php
// Create an iterator to be limited
$fruits = new ArrayIterator(array(
'apple',
'banana',
'cherry',
'damson',
'elderberry'
));
// Loop over first three fruits only
foreach (new LimitIterator($fruits, 0, 3) as $fruit) {
var_dump($fruit);
}
echo "
";
// Loop from third fruit until the end
// Note: offset starts from zero for apple
foreach (new LimitIterator($fruits, 2) as $fruit) {
var_dump($fruit);
}
?>
The above example will output:
string(5) "apple"
string(6) "banana"
string(6) "cherry"
string(6) "cherry"
string(6) "damson"
string(10) "elderberry"
PHP Documentation Group LIMITITERATOR(3)
hi every body,
i donot know how to assign a array varible with a file
see i having file
more file
property1 Name
property2 Address
the above two line are tab Space seperated between the property and its value
i want to seperate it and assign to... (1 Reply)
Hi All,
I have a query....say on server A, I have generated the Private and Public keys and shared the public key with server B.
Now i can surelyconnect(without password) from server A to server B.....
but can i similarly connect from server B to server A as well
Regards (1 Reply)
I have two csv files : say a.csv, b.csv
a.csv looks like this :
property1,property2,100
property3,property4,200
In a.csv, the combination of column1 and column2 will be unique
b.csv looks like this
property1,property2, 300, t1
property1,property2, 400,t2
property3, property4,800,t1... (2 Replies)