我在考虑AccessArray接口和Iterator接口,我在考虑可以将它们组合吗?,我的意思是使用AccessArray设置数组并与Iterator一起使用foreach循环,如果可以的话请帮我举个例子那两个。
class Foo implements ArrayAccess, Iterator {
// Implement interfaces here
}
You can implement as many interfaces as you like.
Note that you are basically asking for ArrayObject
.
class Foo extends ArrayObject
{
private $data = [];
public function __construct()
{
parent::__construct($this->data);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.