CoreIterator
Filepath: phork/php/core/CoreIterator.class.php
The CoreIterator class stores a collection of items that can be iterated through, as well as providing methods to retrieve the first and last items, and to be able to add, modify and remove items. It implements PHP's Interator interface.
There are currently 2 extensions to the CoreIterator class in phork/php/ext/iterators/.
- Associative Iterator - This stores a collection of items as associative data, as opposed to the numeric format of the CoreIterator
- Object Iterator - This stores a collection of objects with validation to make sure the items added are objects
Example
$objList = new ObjectIterator();
$objList->append($objRecord1);
$objList->append($objRecord2);
$objList->append($objRecord3);
$objList->removeByPosition(2);
$objList->rewind();
while (list($intKey, $objRecord) = $objList->each()) {
$objRecord->save();
}