문제

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.

도움이 되었습니까?

해결책

Note that you are basically asking for ArrayObject.

class Foo extends ArrayObject
{
  private $data = [];
  public function __construct()
  {
    parent::__construct($this->data);
  }
}

다른 팁

class Foo implements ArrayAccess, Iterator {
  // Implement interfaces here
}

You can implement as many interfaces as you like.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top