cef8fcc6e3
This is a pure PHP implementation of ArrayObject. It does't match the reference semantics of zend's implementation, but it is much easier to build this in pure PHP, so its a good first step. It is better to have it like this, than to not have it at all.
22 linhas
590 B
PHP
22 linhas
590 B
PHP
<?php
|
|
// Custom ArrayIterator (inherits from ArrayIterator)
|
|
class MyArrayIterator extends ArrayIterator {
|
|
// custom implementation
|
|
}
|
|
|
|
// Array of available fruits
|
|
$fruits = array("lemons" => 1, "oranges" => 4, "bananas" => 5, "apples" => 10);
|
|
|
|
$fruitsArrayObject = new ArrayObject($fruits);
|
|
|
|
// Get the current class name
|
|
$className = $fruitsArrayObject->getIteratorClass();
|
|
var_dump($className);
|
|
|
|
// Set new classname
|
|
$fruitsArrayObject->setIteratorClass('MyArrayIterator');
|
|
|
|
// Get the new iterator classname
|
|
$className = $fruitsArrayObject->getIteratorClass();
|
|
var_dump($className);
|