I was thinking about AccessArray interface and the Iterator interface and i was thinking can we combine them?, I mean Setting up array with AccessArray and use a foreach loop with the Iterator, If can some one please help me with example if it possible to combine those two.
2 Answers
Note that you are basically asking for ArrayObject.
class Foo extends ArrayObject
{
private $data = [];
public function __construct()
{
parent::__construct($this->data);
}
}
3 Comments
KingCrunch
ArrayObject additional Serializable, Countable and instead of Iterator IteratorAggregate and Traversable. The OP maybe doesn't want this, but must say: Don't think so either.Matthew
Yeah, it's definitely more than what he explicitly asked for, but I often see people ultimately reimplementing
ArrayObject because they don't know it exists.Aviel Fedida
Thank you Matthew, becouse of you i understand the concept if built-in behavior, thank you again and have a nice day.