3 // Custom ArrayIterator (inherits from ArrayIterator)
4 class MyArrayIterator
extends ArrayIterator
{
5 // custom implementation
8 // Array of available fruits
9 $fruits = array("lemons" => 1, "oranges" => 4, "bananas" => 5, "apples" => 10);
11 $fruitsArrayObject = new ArrayObject($fruits);
13 // Set the iterator classname to the newly
14 $fruitsArrayObject->setIteratorClass('MyArrayIterator');
15 print_r($fruitsArrayObject->getIterator());