If Iterator::valid() returns false, the foreach() loop will be terminated.
(PHP 5, PHP 7, PHP 8)
Iterator::valid — 检查当前位置是否有效
此函数没有参数。
If Iterator::valid() returns false, the foreach() loop will be terminated.
If your class implements also ArrayAccess interface, you could use as valid() bodyfunction valid(){ return $this->offsetExists($this->position);}